Hi!

Somehow I can't manage to make a button to act as default button in a dialog the way I want to.

I want to
 - create the dialog
 - show it as modal dialog with exec_()
 - make it close when the user
  - explicitely closes it or
  - hits Enter or
  - clicks one of the action buttons ('Find' in my case)
I've tried both setDefault() on the button and using QDialogButtonBox.

This is on my N900 with (1, 0, 0, 'beta', 3), but seems the same on
Windows 0.4.2.

E.g. on windows when I run
 pyside-pyside-examples\examples\dialogs\extension.py
the Find button is highlighted as default button, but when I hit enter
or click the button, the dialog does not close.

The same happens with my code (below) on the N900.

The standard dialogs like QInputDialog.getText behave as expected.

Am I missing something?


Regards,

Dietmar


dlg = QtGui.QDialog(self)
lineEdit = QtGui.QLineEdit()
albumsCheckBox = QtGui.QCheckBox("&Albums/Folders")
albumsCheckBox.setChecked(True)
tracksCheckBox = QtGui.QCheckBox("&Tracks/Titles")
samplerCheckBox = QtGui.QCheckBox("&Include Samplers")
findButton = QtGui.QPushButton("&Find", dlg)
#findButton.setDefault(True)
bb = QtGui.QDialogButtonBox(orientation=Qt.Vertical, parent=dlg)
bb.addButton(findButton, QtGui.QDialogButtonBox.ActionRole)
#bb.addButton(self.quitButton, QtGui.QDialogButtonBox.RejectRole)

leftLayout = QtGui.QVBoxLayout()
leftLayout.addWidget(lineEdit)
leftLayout.addWidget(albumsCheckBox)
leftLayout.addWidget(tracksCheckBox)
leftLayout.addWidget(samplerCheckBox)
#leftLayout.addStretch(1)
#mainLayout = QtGui.QGridLayout()
mainLayout = QtGui.QHBoxLayout()
mainLayout.addLayout(leftLayout)
#mainLayout.addWidget(findButton)
mainLayout.addWidget(bb)
dlg.setLayout(mainLayout)
dlg.setWindowTitle("Search")
findButton.setDefault(True)
res = dlg.exec_()

_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to