简体   繁体   中英

PyQt4 Checkbox not responding - OSX

I am getting a really weird issue here. A simple python app with a checkbox once I click on the checkbox (cb) it doesn't change its state and it doesn't change the GUI visualization.

Any ideas ?

Here is my python snippet

a = QApplication(sys.argv)
w = QWidget()
cb = QCheckBox("Auto-Launch", w)
cb.move(220, 110)
cb.stateChanged.connect(handleLaunch)

I found out what was causing this.

I had a QProgressBar, which was close to the checkbox and though visually it didn't seem that way. In reality was covering the checkbox, so the click wasn't reaching the checkbox at all.

here is the full code with the problem.

from PyQt4.QtGui import *
import sys

a = QApplication(sys.argv)
w = QWidget()
w.resize(320, 240)

cb = QCheckBox("Auto-Launch", w)
cb.move(220, 110)

download_bar = QProgressBar(w)
download_bar.resize(300,50)
download_bar.setValue(0)
download_bar.move(10,110)

w.show()
sys.exit(a.exec_())

and here is the full solution

from PyQt4.QtGui import *
import sys

a = QApplication(sys.argv)
w = QWidget()
w.resize(320, 240)

download_bar = QProgressBar(w)
download_bar.resize(300,50)
download_bar.setValue(0)
download_bar.move(10,110)

cb = QCheckBox("Auto-Launch", w)
cb.move(220, 110)

w.show()
sys.exit(a.exec_())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM