Results 1 to 4 of 4

Thread: Do the layout class can receive the mouse event?

  1. #1
    Join Date
    Oct 2009
    Posts
    32
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question Do the layout class can receive the mouse event?

    Now I convert the WPF program to Qt, because the project need cross-platform. In WPF program, the layout(Panel, Grid, StackPanel...) is also control, so it also can receive the mouse event. but in Qt, the layout(QLayout, QGridLayout...) isn't derived by QWidget, so i want to know if the layout class can receive the mouse event. I write a simple sample, derived a class from QVBoxLayout, find I can't receive the mousePressEvent when I press the mouse in the layout. thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Do the layout class can receive the mouse event?

    A layout is not a widget, it not a visible object, so it makes no sense for it to receive any input.
    Since a QLayout is a QObject, you could use it as an event filter for another widget, but the question is, what would you do with the event then?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Oct 2009
    Posts
    32
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Do the layout class can receive the mouse event?

    Ok, let me explain my question in detail.for example, QVBoxLayout include several controls(such as button, listwidget...), when user press the mouse then move the mouse, the all controls in the QVBoxLayout will move, this is the effect I want to implement. In WPF, the layout is also the control, so it is easy to do the effect. how to do the same effect in Qt? thanks.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Do the layout class can receive the mouse event?

    Maybe you should just use QScrollArea?

    Please notice that when porting an application to a different system/framework you shouldn't try to mimic the original code as much as possible. There are differences between frameworks - different approaches and concepts. Instead you should try to grasp the spirit of the framework you are using and implement your code instead of traslating it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. mouse move event filtering in PyQt4
    By lucaf in forum Qt Programming
    Replies: 1
    Last Post: 4th April 2009, 14:53
  2. Replies: 21
    Last Post: 3rd April 2009, 12:22
  3. Replies: 4
    Last Post: 19th February 2009, 11:10
  4. parent widet does not get mouse event.
    By babu198649 in forum Newbie
    Replies: 1
    Last Post: 27th July 2008, 08:43
  5. Replies: 2
    Last Post: 4th August 2007, 04:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.