[PyKDE] Cannot connect QSplitter signal
Phil Thompson
phil at riverbankcomputing.co.uk
Tue Jul 1 20:32:00 BST 2003
On Tuesday 01 July 2003 7:16 pm, Toru Furukawa wrote:
> Thanks for many advices.
>
> On Sat, 28 Jun 2003 15:09:34 +0100
>
> Phil Thompson <phil at riverbankcomputing.co.uk> wrote:
> > > Platform: WindowsXP / Python2.2.2 / Qt2.3 / PyQt-3.6
>
> ...
>
> > > s = QSplitter()
>
> ...
>
> > > app.connect(s, SIGNAL("childEvent(QChildEvent *e)"), PYSIGNAL("foo"))
>
> ...
>
> > childEvent() isn't a signal. Even if it was you shouldn't include the
> > argument name (ie. "e") in the signature string. Also, a QChildEvent
> > deals with the addition and removal of children in a QObject hierarchy.
> >
> > The solution is to sub-class QSplitter and re-implement
> > mouseDoubleClickEvent().
>
> That is it. The code below shows the way, I guess.
>
> Now, I found MySplitter.event() is called when I resize, hide, maximize
> or minimize widget, but MySplitter.event() and
> MySplitter.mouseDoubleClicked() are not called. I am trying to hide a
> child widget when double-clicking on a splitter (separator or whatever
> you call the long lectangular stuff between child widgets), as in
> Mozilla's side bar.
>
> How can I detect mouse events on the splitter widget?
>
> ########
> from qt import *
> class MySplitter(QSplitter):
> def event(self, e):
> print "#", e
> return QSplitter.event(self, e)
> def mouseDoubleClickEvent(self, e):
> print "*", e
> QSplitter.mouseDoubleClickEvent(self, e)
> app = QApplication([])
> s = MySplitter()
> app.setMainWidget(s)
> QWidget(s)
> QWidget(s)
> s.show()
> app.exec_loop()
> ########
>
> Phil told me that the code works fine to him. I wonder it is platform
> dependent.
Just to clarify, the double-click is received by the splitter if you click on
either of the QWidgets - not if you click on the "long rectangular stuff"
between them.
Phil
More information about the PyQt
mailing list