Results 1 to 13 of 13

Thread: Extended Tooltip

  1. #1
    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 Extended Tooltip

    Hi All,
    My problem is somewhat related to the tooltip timeout.

    I want to display a tooltip as in Visual Studio while debigging -
    The tooltip has +/- button and expands more as the + is hovered on.

    I understand that this must be custom widget to behave like a tootip.

    What I want to achieve is this -
    Say i hover a widget, tooltip is shown. Now I want is if the tooltip is shown for more than 1-2 seconds, it should show some detailed tooltip. This detailed tooltip can be stored in whatsThis of a widget. How do I achieve this ??
    One solution is making custom widgets. But this will be tedious and inefficient. Also it cant be merged with some existing code easily.

    What I did was - installed a event filter on QApplication. In this event I am checking for QEvent::ToolTip. But the problem is - How do I extract the tooltip for the WIDGET/ACTION that is under the mouse ?? If u use toolBar()->addAction(), Qt adds a push button for it. Now in the filter, I am getting focusWidget() as QPushButton, but am not able to extract the tooltip for this pushbutton.

    Any ideas how to do it ?

    EDIT : I wish there was a function in Qt like QWidget::setToolTip(QToolTip *); And QToolTip class being something like -
    Qt Code:
    1. class QToolTip
    2. {
    3. QWidget * widgetToShow;
    4. QString tooltip;
    5. QString tooltipDetail;
    6. }
    To copy to clipboard, switch view to plain text mode 


  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Extended Tooltip

    I'm not sure if the delay of tool tip events can be adjusted but for highly customized tool tips take a look at QxtToolTip.
    J-P Nurmi

  3. #3
    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: Extended Tooltip

    Well QxtToolTip is what I had in mind,,,, but it wont solve my problem.
    It cant be integrated into existing applications.

    What I wanted is a way where I could use the exisiting QWidget::toolTip() and QWidget::whatsThis() to get the QSTring, and then display tooltip initiaaly, followed by whatsThis(). This cud be easily integrated in existing applications provided one can extract the QAction under mouse position

    About the QToolTip format I gave, I wish Qt had something like that without the user being bothered to catch the tooltip event and show himself. It should have been as easy as QWidget::setToolTip(QString), the only thing that we cud pass QWidget instead of QString

  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: Extended Tooltip

    You mean you want it for applications for which you don't have the source code?

  5. #5
    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: Extended Tooltip

    No,,
    I want it for applications which I have source code.
    But in a way that I need to make minimal changes.

    I guess I need to look more into QxtToolTip. How do we get the source for it ? What I understand is, if I use QxtToolTip, I will need to replace all my QWidget::setToolTip() functions. Am I right ??

    Also one important question - In my application, most of the tooltip are set for QAction. How do I handle this , if I use QxtTooltip ?? or may be like installing filter

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Extended Tooltip

    Quote Originally Posted by aamer4yu View Post
    I guess I need to look more into QxtToolTip. How do we get the source for it ?
    Just download the package from libqxt.org.

    What I understand is, if I use QxtToolTip, I will need to replace all my QWidget::setToolTip() functions. Am I right ??
    Well, QxtToolTip doesn't use QWidget::toolTip property but just catches QEvent::ToolTip for the registered widget and shows the associated tooltip widget.

    Also one important question - In my application, most of the tooltip are set for QAction. How do I handle this , if I use QxtTooltip ?? or may be like installing filter
    For example QToolBar provides QToolBar::widgetForAction() so that you can use those individual action widgets to associate tooltip widgets. But as it's mentioned in QxtToolTip docs, it might not be a good idea to flood your application full of complex tooltip widgets. Do you really need complex tooltip widgets for something like actions?
    J-P Nurmi

  7. #7
    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: Extended Tooltip

    Quote Originally Posted by aamer4yu View Post
    No,,
    I want it for applications which I have source code.
    But in a way that I need to make minimal changes.
    Apply an event filter on the application object and intercept tooltip events and handle them yourself instead of letting the application do it.

  8. #8
    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: Extended Tooltip

    But as it's mentioned in QxtToolTip docs, it might not be a good idea to flood your application full of complex tooltip widgets.
    I agree.

    Do you really need complex tooltip widgets for something like actions?
    Not really...what I wanted is, show the user simple tooltip, and also give the option to get more detailed tooltip(say, whatsThis). But I wanted simple and detailed tips in one go - either show the detailed one after some delay / or provide some button/icon to expand the tip

    I was looking for ways to use the already set tooltips and whatsthis in the application.

  9. #9
    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: Extended Tooltip

    Apply an event filter on the application object and intercept tooltip events and handle them yourself instead of letting the application do it.
    I was doing exactly that

    But read my FIRST post. I have bolded the problem - How do I extract the tooltip for the WIDGET/ACTION that is under the mouse ??

  10. #10
    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: Extended Tooltip

    That's kind of simple. You get a pointer to the object in the filter. Cast it to a widget using qobject_cast and ask for the tooltip using QWidget::toolTip().

  11. #11
    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: Extended Tooltip

    Correct me if am getting it wrong -
    You get a pointer to the object in the filter. Cast it to a widget using qobject_cast and ask for the tooltip using QWidget::toolTip().
    I had installed filter on qApp. Wont the pointer to the object be of QApplication type ??

    I had tried QApplication::activeWindow and QApplication::focusWidget. But I was not getting the proper pointer. In QApplication::focusWidget I was able to get a pointer to widget, which was of QPushButton type. But I needed a pointer to the action

  12. #12
    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: Extended Tooltip

    Quote Originally Posted by aamer4yu View Post
    I had installed filter on qApp. Wont the pointer to the object be of QApplication type ??
    That's the whole point - no If you examine the docs, you'll notice that they say that by applying an event filter on the application object you can catch events for each and every object handled by the application. I actually never tried it, but if they say so, then I don't see why it shouldn't work. If it turns out to be a bug in the docs, then you can reimplement QCoreApplication::notify to gain total control of the event mechanism. Nevertheless, I'd try the event filter first:

    Quote Originally Posted by Qt docs
    Installing an event filter on QCoreApplication::instance(). Such an event filter is able to process all events for all widgets, so it's just as powerful as reimplementing notify(); furthermore, it's possible to have more than one application-global event filter. Global event filters even see mouse events for disabled widgets.

  13. #13
    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: Extended Tooltip

    Thanks
    That's the whole point - no
    That did the trick. I was under the impression that the QObject* u get in eventFilter, is that of the QOBject on which u had installed the filter. I had installed filter on the QApplication, so I thought I wud get QApplication* pointer

    But it gives the pointer of the object it is intended for :-)

    Now am able to implement what I wanted, jst have to play with position little. and also I can show my custom widgets now

Similar Threads

  1. Displaying tooltip for points in the graph
    By Ankitha Varsha in forum Qt Programming
    Replies: 4
    Last Post: 29th January 2008, 12:08
  2. Anthias : An extended terminal
    By ePharaoh in forum Qt-based Software
    Replies: 5
    Last Post: 9th January 2008, 16:55
  3. Hot to set the tooltip of button
    By santosh.kumar in forum Qt Programming
    Replies: 3
    Last Post: 1st November 2007, 13:07
  4. QGraphicsItem tooltip behavior
    By darksaga in forum Qt Programming
    Replies: 6
    Last Post: 22nd August 2007, 18:50
  5. extended selection in q3listview
    By sreedhar in forum Qt Programming
    Replies: 7
    Last Post: 13th November 2006, 10:03

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.