Hi everybody, Look at the following code. Due to some external constraints, I am compelled to put a QMainWindow inside a QDialog. When I press "return" in the QLineEdit, all happens as if self.optimize_button is clicked, calling self.optimize(). The workaround I have found is to set this button invisible. But I would like to understand what happens. Is it a normal behavior?
Thanks in advance, Julien #####################################" import sys from PySide import QtCore, QtGui from PySide.QtGui import * class MainWindowEnterMakesPushButton( QMainWindow ): def __init__( self ): super( MainWindowEnterMakesPushButton, self ).__init__() q = QWidget() self.v = QVBoxLayout() q.setLayout( self.v ) self.optimize_button = QPushButton( "optimization 1" ) self.optimize_button.clicked.connect( self.optimize ) #self.optimize_button.setVisible(False) self.optimize_button2 = QPushButton( "optimization 2" ) self.optimize_button2.clicked.connect( self.optimize2 ) self.v.addWidget( self.optimize_button ) self.v.addWidget( self.optimize_button2 ) self.max_pres_lineedit = QLineEdit() self.v.addWidget( self.max_pres_lineedit ) self.dock_widget = QDockWidget() self.dock_widget.setWidget( q ) self.addDockWidget( QtCore.Qt.LeftDockWidgetArea, self.dock_widget ) def optimize( self ): print "optimization 1" def optimize2( self ): print "optimization 2" class MainForm(QtGui.QDialog): def __init__(self, *args, **kwargs): super(MainForm, self).__init__(*args, **kwargs) self.l = QVBoxLayout() self.setLayout( self.l ) self.main_window = MainWindowEnterMakesPushButton() self.l.addWidget( self.main_window ) app = QApplication( sys.argv ) dialog = MainForm( ) dialog.show() app.exec_() _______________________________________________ PySide mailing list PySide@qt-project.org http://lists.qt-project.org/mailman/listinfo/pyside