Cool. I added and modified your code to my main window and catch the Close event type. Will try later on dock widgets. Thanks.
From: Brian Kelley [mailto:[email protected]] Sent: Monday, December 22, 2008 6:22 PM To: Iliya Gogolev; piotr maliński; [email protected] Subject: Re: [PyQt] QDockWidgetquestion If you want to catch mouse events in a parent, you should install or override an eventFilter. For example, here is an eventFilter I use on my main window to catch close events. You can catch mouse events or others in this way. “obj” is the object receiving the event and “event” is the event being received. Note that doing it this way is tricky. You may be better off making your own subclasses for all your widgets that can communicate to the mainwindow. def eventFilter(self, obj, event): controller = self.controller if obj == self.mw and event.type() == QEvent.Close: if controller and controller.db.ProcessesRunning(): opt = QtGui.QMessageBox.question(self.mw, "Running Workflows", "There are workflows still running, would you like to save these?\n" "(Saved workflows will restart when the throughput is run again.)", QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel) if opt == QtGui.QMessageBox.Cancel: event.setAccepted(False) return True self.controller.db.disconnect() self.controller.db.KillRunningProcesses() if res == QtGui.QMessageBox.Discard: self.controller.db.ClearRunningProcesses() return QObject.eventFilter(self, obj, event) On 12/22/08 11:16 AM, "Iliya Gogolev" <[email protected]> wrote: Yes, you are right. But I did it for checking if i can catch the event :) I added mousePressEvent & mouse ReleaseEvent: def mouseMoveEvent (self, p_event) : print "CustomDockWidget mouseMoveEvent" event.ignore() def mouseReleaseEvent(self, event) : print " CustomDockWidget mouseReleaseEvent" event.ignore() I also added the output(or breakpoint) and it did not work :) Actually I want to catch the mouse move event in the parent - QMainWindow, when the left mouse button pressed. I want to make something similar to Widget Box of Qt Designer(left docked side). For example, when user wants to add a button to a canvas, he select it, the button layout is shown and then user can drag and drop it to the canvas. I think the way to implement it is: when one of the buttons of Widget Box was selected (by pressing left mouse button and it's still pressed), cache the mouse event in MainWindow and change a position of button layout entity. -----Original Message----- From: [email protected] [HYPERLINK "mailto:[email protected]"mailto:[email protected]] On Behalf Of piotr malinski Sent: Monday, December 22, 2008 5:38 PM To: [email protected] Subject: Re: [PyQt] QDockWidgetquestion If you want to catch mouse events that happen on the docked widget then yout CustomDockWidget must have such methods (def mouseSomethingEvent(self, event)). _______________________________________________ PyQt mailing list [email protected] HYPERLINK "http://www.riverbankcomputing.com/mailman/listinfo/pyqt"http://www.riverbankcomputing.com/mailman/listinfo/pyqt -- Internal Virus Database is out-of-date. Checked by AVG. Version: 7.5.549 / Virus Database: 270.9.10/1814 - Release Date: 11/26/2008 8:53 PM Internal Virus Database is out-of-date. Checked by AVG. Version: 7.5.549 / Virus Database: 270.9.10/1814 - Release Date: 11/26/2008 8:53 PM I tried it too. It did not help. Sorry, I use QToolBox instead QTreeWidget, but there's no sense From: Brian Kelley [HYPERLINK "mailto:[email protected]"mailto:[email protected]] Sent: Monday, December 22, 2008 5:00 PM To: Iliya Gogolev; [email protected] Subject: Re: [PyQt] QDockWidgetquestion QDockWidgets behave a little different than normal widgets. You need to call "setWidget" to place a widget in a dock widget. HYPERLINK "http://doc.trolltech.com/4.4/qdockwidget.html"http://doc.trolltech.com/4.4/qdockwidget.html Try: CustomDockWidget(QDockWidget): def __init__(self,parent): QDockWidget.__init__(self, parent) self.tree = QTreeWidget(self) self.setWidget(self.tree) On 12/22/08 9:54 AM, "Iliya Gogolev" <[email protected]> wrote: Hi everyone! I added QTreeWidget to QDockWidget and then added it to MainWindow by addDockWidget function: """"""""""""""""""""""""""""""""""""""""""" CustomDockWidget(QDockWidget): def __init__(self,parent): QDockWidget.__init__(self, p_parent) self.tree = QTreeWidget(self) . . . """"""""""""""""""""""""""""""""""""""""""" class MainWindow(QMainWindow): def __init__(self, p_parent = None): QMainWindow.__init__(self, p_parent) self.customWidget = CustomDockWidget(self) self.addDockWidget (Qt.LeftDockWidgetArea, self.customWidget) . . . I'm trying to catch mouse event in MainWindow when I click on the QTreeWidget and no success. Any ideas? Thanks Internal Virus Database is out-of-date. Checked by AVG. Version: 7.5.549 / Virus Database: 270.9.10/1814 - Release Date: 11/26/2008 8:53 PM _______________________________________________ PyQt mailing list [email protected] HYPERLINK "http://www.riverbankcomputing.com/mailman/listinfo/pyqt"http://www.riverbankcomputing.com/mailman/listinfo/pyqt Internal Virus Database is out-of-date. Checked by AVG. Version: 7.5.549 / Virus Database: 270.9.10/1814 - Release Date: 11/26/2008 8:53 PM Internal Virus Database is out-of-date. Checked by AVG. Version: 7.5.549 / Virus Database: 270.9.10/1814 - Release Date: 11/26/2008 8:53 PM Internal Virus Database is out-of-date. Checked by AVG. Version: 7.5.549 / Virus Database: 270.9.10/1814 - Release Date: 11/26/2008 8:53 PM _______________________________________________ PyQt mailing list [email protected] HYPERLINK "http://www.riverbankcomputing.com/mailman/listinfo/pyqt"http://www.riverbankcomputing.com/mailman/listinfo/pyqt Internal Virus Database is out-of-date. Checked by AVG. Version: 7.5.549 / Virus Database: 270.9.10/1814 - Release Date: 11/26/2008 8:53 PM Internal Virus Database is out-of-date. Checked by AVG. Version: 7.5.549 / Virus Database: 270.9.10/1814 - Release Date: 11/26/2008 8:53 PM
_______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
