Results 1 to 10 of 10

Thread: Tool Tip

  1. #1
    Join Date
    Sep 2008
    Posts
    32
    Thanks
    7

    Smile Tool Tip

    Hi all,

    I am usuing the toolTip() function for displaying the tool tip. The tool tip disappears after some seconds. My requirement is "As long as the mouse is at that location that tool tip should be displayed." After the mouse moved from that location, the tool tip should goes away.

    Could any one please help me for implementing this?

    Thanks a lot in advance.

    Thanks and Regards
    Rakesh lenka

  2. #2
    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: Tool Tip

    Well, am not sure if any Application setting can be modified to achieve this.

    But you can do this -
    Inherit QToolTip, or make a new class , reimplement the mouse events.
    Next step is to install a event filter on the QApplication, and catch QEvent::tooltip ( am not sure if its exactly same). And when u catch the event, show your tooltip class instead of the QTooltip.
    You can close the custom tooltip on focusoutEvent.
    Hope this helps u

  3. #3
    Join Date
    Sep 2008
    Posts
    32
    Thanks
    7

    Default Re: Tool Tip

    Hi,

    Thanks a lot for your response. I am new to Qt. I am not sure how to install a event filter on the QApplication, and catch QEvent::tooltip .Could you please elaborate more or can give a sample code .

    Thanks and Regards
    Rakesh

  4. #4
    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: Tool Tip

    EVen if u are new, I guess u might have noticed the Search page
    You can many related threads,, (ex 1, ex 2 )

  5. #5
    Join Date
    Sep 2008
    Posts
    32
    Thanks
    7

    Default Re: Tool Tip

    Hi Aamer,

    Thanks a lot. Now I got to know how to install an event filter on the QApplication. But I am not able to find which mouse events has to be reimplemented in the new Tool tip class. Could you please provide some help for this as well.

    Regards,
    Rakesh

  6. #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: Tool Tip

    I dont think you need to work on mouse move events,
    In the filter you will get a QEvent::ToolTip event. catch it and show ur tooltip widget.
    In the custom tooltip widget, reimplement focusOut event and close the widget on focusout.

    Hope u get the idea

  7. #7
    Join Date
    Sep 2008
    Posts
    32
    Thanks
    7

    Default Re: Tool Tip

    Hi Aamer,

    Thanks a lot. I am having lot of tool tips in my application. It's really tedious to implement lot of widgets for those.

    I have one more idea. There is an attribute Qt::WA_AlwaysShowToolTips. Can we use that? I tried that with my buttons, It's not working.

    static bool on = true;
    m_FastBackwardButton->setAttribute(Qt::WA_AlwaysShowToolTips, on);


    This is for my testing purpose.Latter on I will make the on event true and false depending on the mousehover event. This is not working.

    Could you please let me know if there is anything wrong.

    Thanks and Regards
    Rakesh Lenka

  8. #8
    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: Tool Tip

    Did you read the documentation of Qt::WA_AlwaysShowToolTips? It doesn't change the duration tooltips are visible, but enables tooltips for inactive windows.
    J-P Nurmi

  9. #9
    Join Date
    Sep 2008
    Posts
    32
    Thanks
    7

    Default Re: Tool Tip

    Hi JPN,

    Thanks a lot for your response. You are right. WA_AlwaysShowToolTips enables tooltips for inactive windows. I was wrong.

    Is there any other easier way to change the duration of tool tips without implementing custom widgets for each of the tool tips.

    Thanks and regards,
    Rakesh Lenka

  10. #10
    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: Tool Tip

    Quote Originally Posted by Rakesh_Kumar View Post
    Is there any other easier way to change the duration of tool tips without implementing custom widgets for each of the tool tips.
    QToolTip implementation uses hard coded values. So, currently the only way is to modify Qt sources. You can try to send a suggestion to make it adjustable, though.
    J-P Nurmi

Similar Threads

  1. Customizing a Widget's Tool Tip.
    By Cutey in forum Qt Programming
    Replies: 1
    Last Post: 24th July 2008, 08:08
  2. Tool Buttons...
    By csvivek in forum Qt Tools
    Replies: 1
    Last Post: 9th May 2008, 07:44
  3. Open source automated testing tool for Qt App
    By William Wilson in forum Qt Programming
    Replies: 21
    Last Post: 5th December 2007, 16:56
  4. tool tip
    By jnana in forum Qt Programming
    Replies: 1
    Last Post: 1st October 2007, 13:55
  5. Problem with unified tool bar on Mac OS X
    By m_e in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2007, 11:21

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.