Results 1 to 14 of 14

Thread: Embedded Widget events question

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Embedded Widget events question

    Hi to all!

    I have some widgets, embedded on graphics view through proxy widget. I just want to know, which which event is emited and from which obejct (view, proxy, scene, or widget itself) when the mouse button is clicked inside this embedded widget? What I want to achive is when some widget is "selected", it gets zoomed.

    Sincerely,
    Marko
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Embedded Widget events question

    What did you already try?
    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.


  3. #3
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Embedded Widget events question

    maybe you can reimplement
    Qt Code:
    1. bool QObject::eventFilter ( QObject * watched, QEvent * event )
    To copy to clipboard, switch view to plain text mode 
    in the parent widget and check which child widget gets the event and which event.

  4. The following user says thank you to montylee for this useful post:

    MarkoSan (20th November 2009)

  5. #4
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Embedded Widget events question

    Quote Originally Posted by montylee View Post
    maybe you can reimplement
    Qt Code:
    1. bool QObject::eventFilter ( QObject * watched, QEvent * event )
    To copy to clipboard, switch view to plain text mode 
    in the parent widget and check which child widget gets the event and which event.
    How do I get a list of child widgets?
    Qt 5.3 Opensource & Creator 3.1.2

  6. #5
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Embedded Widget events question

    i don't have much idea about graphics view but i think in eventFilter() function, you can compare the object type with the object type of the child widgets. Read these links for more info:
    http://doc.trolltech.com/4.2/eventsandfilters.html
    http://doc.trolltech.com/4.2/qobject.html#eventFilter

  7. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Embedded Widget events question

    What I want to achive is when some widget is "selected", it gets zoomed.
    May be the embedded Dialog example is something similar to your needs. The dialog gets expanded when hovered over.

  8. #7
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Embedded Widget events question

    I know that, but hoverEvent is not ok, or is it. The final application will be touch screen based and I want to catch an event once the user will press inside of the region one of the embedded widgets and I do not know, which event to catch. Furthermore, I do not even know, which object will emit signal or event, Scene, View, ProxyWidget or Widget itself?
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Embedded Widget events question

    Again (I hate to repeat myself...), what did you already try to solve your problem?

    You did try the obvious - QGraphicsScene::selectionChanged(), QGraphicsScene::selectedItems() and QWidget::mousePressEvent(), right?
    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.


  10. #9
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Embedded Widget events question

    Well, then I must connect QWidget::mousePressEvent to QGraphicsScene's itemChanged signal?
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Embedded Widget events question

    It would be hard to connect an event to a signal but I'm sure you already know it. I mean, you did try it, yes?
    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.


  12. #11
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Embedded Widget events question

    Well, Ive' reimplemented mousePressEvent in a following fashion:
    Qt Code:
    1. void MerchandiseWidget::mousePressEvent (QMouseEvent* event)
    2. {
    3. if(event->button()==Qt::LeftButton)
    4. {
    5. if(windowState()==false)
    6. {
    7. resize(QSize(WIDGET_WIDTH+WIDGET_WIDTH_DELTA, WIDGET_HEIGHT+WIDGET_HEIGHT_DELTA));
    8. setResizedState(true);
    9. }
    10. else
    11. {
    12. resize(QSize(WIDGET_WIDTH, WIDGET_HEIGHT));
    13. setResizedState(false);
    14. } // if
    15. } // if
    16. }
    To copy to clipboard, switch view to plain text mode 
    Now, the widget gets resized, but if I click on it again, it does not get smaller. Can you please tell me why?
    Qt 5.3 Opensource & Creator 3.1.2

Similar Threads

  1. Replies: 1
    Last Post: 30th October 2009, 08:52
  2. Replies: 2
    Last Post: 21st June 2009, 06:04
  3. resizing events of a custom widget in a layout
    By Rooster in forum Qt Programming
    Replies: 7
    Last Post: 16th February 2008, 10:52
  4. Custom tab widget question
    By PrimeCP in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 11:17
  5. Forwarding mouse events to another widget.
    By yogeshm02 in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2006, 13:25

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
  •  
Qt is a trademark of The Qt Company.