<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:D="DAV:" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<title>Re: [PyQt] QDockWidgetquestion</title>
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:56.7pt 42.5pt 56.7pt 85.05pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Cool. I added and modified your code to my main window and catch
the Close event type. Will try later on dock widgets. Thanks.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Brian Kelley
[mailto:kelley@eyesopen.com] <br>
<b>Sent:</b> Monday, December 22, 2008 6:22 PM<br>
<b>To:</b> Iliya Gogolev; piotr maliński; pyqt@riverbankcomputing.com<br>
<b>Subject:</b> Re: [PyQt] QDockWidgetquestion<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:11.0pt;
font-family:"Calibri","sans-serif"'>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:</span><o:p></o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:11.0pt;
font-family:"Calibri","sans-serif"'>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></span><o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p><span style='font-size:10.0pt'>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
8:53 PM</span><o:p></o:p></p>
</div>
</body>
</html>
<BR>
<P><FONT SIZE=2>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 8:53 PM<BR>
</FONT> </P>