Results 1 to 8 of 8

Thread: QToolTip

  1. #1
    Join Date
    Aug 2006
    Location
    Chennai, India
    Posts
    34
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QToolTip

    QToolTip class of qt 3.3.4 has several functions. But QToolTip class of qt 4.1.4 does not have so much functions, even no constructor is available. Is there any alternative class for QToolTip? Or how to use that class in efficient way?

    Regards,
    Suresh

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

    What exactly do you want to do with it? You have a static QToolTip::showText() method. Do you need anything more?

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

    You can construct your own custom tooltips by using a widget with Qt::ToolTip window flag set. See Tooltips Example to get to know how and when to trigger custom tooltips. You may adapt some ideas from QToolTip implementation (src/gui/widgets/qtooltip.cpp if I remember right) as well.
    J-P Nurmi

  4. #4
    Join Date
    Aug 2006
    Location
    Chennai, India
    Posts
    34
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QToolTip

    I will go through the example. If any problem i get back to you.

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

    Oh, and by the way, QToolTip supports images to be embedded out of the box by using appropriate html tags. One negative point in this approach is that the image must exist as a file.

    Eg. something like
    Qt Code:
    1. widget->setToolTip("<img src=\"image.jpg\"/>");
    To copy to clipboard, switch view to plain text mode 

    Not sure what would you actually like to put in a tooltip, though..
    J-P Nurmi

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

    Quote Originally Posted by jpn
    One negative point in this approach is that the image must exist as a file.
    No it doesn't. You can use Qt resource system here:
    Qt Code:
    1. widget->setToolTip("<img src=':/image.jpg'/>");
    To copy to clipboard, switch view to plain text mode 

  7. #7
    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: QToolTip

    I meant that a dynamically created image (which is not loaded from a file and neither does not exist as a file), for example a screenshot thumbnail, custom painting, or similar would have to be dumped to a temp file just to be able to show it in a QToolTip using html.
    J-P Nurmi

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

    You can try using QTextDocument::addResource(). I'm pretty sure tooltips use QTextDocument. However it's probably not easily accessible from within the API.

Similar Threads

  1. [QT3] QToolTip with Images (QPixMap) ?
    By BrainB0ne in forum Qt Programming
    Replies: 4
    Last Post: 27th January 2006, 08: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.