Results 1 to 7 of 7

Thread: QTabWidget - long pressure on tab

  1. #1
    Join Date
    Mar 2015
    Posts
    20
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Symbian S60

    Default QTabWidget - long pressure on tab

    Hallo,
    working with QTabWidget, i have to intercept an event different from tabBarClicked(int) and tabBarDoubleClicked(int) (but they two as well): an event like "tabBarLengthenedPressure" as my customer wants to use this action to open a dialog and insert some data related to currentWidget.
    How could I perform that?

    Helps&hints appreciated, thank you very much!

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidget - long pressure on tab

    Hi,

    Use a Timer. When you get a "mousePressEvent" you can start the timer. On "mouseReleaseEvent" you can stop it. If the timer fires you can open the dialog.
    Òscar Llarch i Galán

  3. #3
    Join Date
    Mar 2015
    Posts
    20
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Symbian S60

    Default Re: QTabWidget - long pressure on tab

    Thank you ^NyAw^,
    very good hint!
    I'll create a new class derived from QTabBar and implementing my widget (instead of adding my widget directly to the QTabWidget).
    I'll reimplement both: virtual void mouseMoveEvent ( QMouseEvent * event ) and virtual void mousePressEvent ( QMouseEvent * event ) and manage a QTimer "among" them.
    It must work !

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidget - long pressure on tab

    I think QElapsedTimer will better than QTimer.

  5. #5
    Join Date
    Mar 2015
    Posts
    20
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Symbian S60

    Default Re: QTabWidget - long pressure on tab

    Great!
    Thank you, Lesiok!

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTabWidget - long pressure on tab

    I'll create a new class derived from QTabBar
    You really don't need to do that. You can simply install an event filter on your standard tab widget or tab bar and handle the events in that. Deriving from a QWidget just to handle one or two events is usually more work than the benefit you gain, and will probably lead to bugs. Easier to use the mechanism Qt provides for solving exactly this kind of problem.

  7. #7
    Join Date
    Mar 2015
    Posts
    20
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Symbian S60

    Default Re: QTabWidget - long pressure on tab

    Ok, thank you!

Similar Threads

  1. Replies: 6
    Last Post: 21st August 2013, 13:53
  2. It was a long journey
    By zlatko in forum General Discussion
    Replies: 0
    Last Post: 9th January 2013, 23:11
  3. qDebug() and long long int on WIN
    By iw2lsi in forum Qt Programming
    Replies: 3
    Last Post: 21st March 2012, 06:47
  4. Replies: 0
    Last Post: 26th June 2010, 01:40
  5. what to do during long calculation?
    By Weilor in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 13:11

Tags for this Thread

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.