[Qt-interest] How to lock QSplitter contents?

Malyushytsky, Alex alex at wai.com
Mon Sep 7 22:24:19 CEST 2009


I am glad you found either solution,
But you are wrong saying that installing filter is too complex.

It is pretty useful technique and is widely used if you want to change behavior of the class in result of specific event (especially when overriding the class is undesirable).

http://doc.trolltech.com/4.5/qobject.html#installEventFilter

All you had to do is override 1 function in QObject derived class (filter)

bool MouseEventEater::eventFilter(QObject *obj, QEvent *event)
 {
     if (event->type() == QEvent::QMouseEvent) {
         // no reaction on mouse is desired
         return true;
     } else {
         // standard event processing
         return QObject::eventFilter(obj, event);
     }
 }

// And 2 lines of code which will create event filter

MouseEventEater* filterObj = new MouseEventEater(this);
splitter->handle( 1 )->installEventFilter(filterObj);

Is it really way too complicated?

Regards,
   Alex

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Sergei Stolyarov
Sent: Sunday, September 06, 2009 12:50 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] How to lock QSplitter contents?

It's too complex way, I don't want to filter messages queue or
something like. And also there is problem with handle width, because
handleWidth property cannot be used to set witdh to 0 (platform and
style dependent).

On Sat, Sep 5, 2009 at 4:44 AM, Malyushytsky, Alex<alex at wai.com> wrote:
> I have not tested, but splitter is moved by mouse, so you could
> install a filter (void QObject::installEventFilter ( QObject * filterObj ) )
> and prevent QSplitterHandle to receive the related events, which I believe are:
>
> void QSplitterHandle::mousePressEvent(QMouseEvent *e)
> void QSplitterHandle::mousePressEvent(QMouseEvent *e)
> void QSplitterHandle::mouseReleaseEvent(QMouseEvent *e)
>
> This means user would not be able to move anything.
> Also you would need to fix the cursor for QSplitterHandle do not show split cursor.
> It is set in setOrientation.
> You may just set normal cursor instead.
>
> Regards,
>  Alex
>
>
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Sergei Stolyarov
> Sent: Friday, September 04, 2009 9:31 AM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] How to lock QSplitter contents?
>
> Hello.
>
> I want to lock QSplitter''s widgets, i.e. hide handles and don't allow
> resizing using mouse. Is it possible? I've tried to hide handles but
> hide() method on QSplitter:handle() results doesn't hide anything
> actually. Also tried to set handle width to 0 — with the same result.
>
> --
> Sergei Stolyarov
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
> ---------------------------------------------------------------------------------------------------
> Weidlinger Associates, Inc. made the following annotations.
>
> “This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”
>
> “Please consider our environment before printing this email.”
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



--
Sergei Stolyarov

_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest

“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”




More information about the Qt-interest-old mailing list