Hi Sébastien, This sounds to me like an event loop problem.
The MessageBox::question static method creates its own event loop and then returns. So that's probably the reason it works. Are you creating the QLabel widget in the same thread as the GUI application thread? I seem to remember a limitation, when working on multithread Qt applications with a GUI. From the "Rapid GUI Programming with Python and Qt" book: PyQt applications always have at least one thread of execution, the primary (initial) thread. In addition, they may create as many secondary threads as they need. However, if the application has a GUI, the GUI operations, such as executing the event loop, may only take place in the primary thread. -- chapter 19. Multithreading. Hope this helps! Alberto SOTO _______________________________________________________________________________________________________ From: pyside-boun...@lists.pyside.org [mailto:pyside-boun...@lists.pyside.org] On Behalf Of Sébastien Sablé Sablé Sent: mercredi 8 février 2012 11:35 To: pyside@lists.pyside.org Subject: [PySide] PySide in a C++ application using Qt Hi, I am using PySide 1.1.0. And I would like to use it inside a C++ application that already uses Qt and provides an embedded Python interpreter. I tried something like that: from PySide import QtGui app = QtGui.QApplication.instance() print app wid = QtGui.QLabel("Whatever") wid.resize(450, 150) wid.setWindowTitle('Simple') wid.show() Since there is already a running QApplication, I do not create a new one. There is also a running event loop in another thread since the application interface reacts. This code snippet works partially: a new window is created, with a "simple" title, but the text inside it is never displayed and the windows does not react at all: I can't move it, resize it or anything. If I call "wid.repaint()", the text inside the window is correctly refreshed; however the window still does not react to any event. I also tried to create a message box like that: QtGui.QMessageBox.question(wid, 'Message', "Existing app: %r" % app, QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) This time the message box reacts correctly: it is correctly displayed, it shows the existing QApplication object and the buttons react. A screenshot of the result can be seen here: http://dl.free.fr/dey2Tzig3 It seems as if the QLabel I created does not receive any event. Do you have any idea of how I can fix that? Should I open a bug concerning this behavior? Thanks in advance Sébastien Sablé _______________________________________________ PySide mailing list PySide@lists.pyside.org http://lists.pyside.org/listinfo/pyside