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