私はpython2.7とPyQt4を使用します。私は、ボタンボックスとテーブルウィジェットで簡単なアプリケーションを作成しました。表のセルを編集して[OK]ボタンを押すと、セルエディタは常に消えます。しかし、app.setStyleSheet(s)
行を追加すると、OKボタンを押してもセルエディタが消えません。何が起こっている?スタイルシートがQTableWidgetの動作に影響するのはなぜですか?
import sys
from PyQt4 import QtGui
class Widget(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
l = QtGui.QVBoxLayout(self)
table = QtGui.QTableWidget()
table.setColumnCount(3)
table.setRowCount(5)
l.addWidget(table)
l.addWidget(QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel))
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
s = "QWidget{background:red;}"
# app.setStyleSheet(s)
app.setStyleSheet(s)
mw = QtGui.QMainWindow()
w = Widget()
mw.setCentralWidget(w)
mw.show()
sys.exit(app.exec_())