Results 1 to 2 of 2

Thread: QToolTip Qusetion

  1. #1
    Join Date
    Mar 2010
    Posts
    69
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QToolTip Qusetion

    Hi Everyone,
    Can I show a ToolTip without hovering over the widget? I have seen QToolTip showText method, which requires a point but how can I get that point?

    For your kind information, I am creating a login dialog where user will enter username and password. If the login details is not valid then I want to show a tool tip on the password field saying that "Your login details is not valid" but without hovering over the password field. The message should come automatically.

    Is it achievable?

    Thanks.
    Chandan

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QToolTip Qusetion

    Since QToolTip::showText() expects position in global screen coordinates, you can calculate position of tooltip using the QWidget::mapToGlobal():
    Qt Code:
    1. QToolTip::showText(lineEdit->mapToGlobal(QPoint()) + QPoint( lineEdit->width(),0 ),"string to show");
    To copy to clipboard, switch view to plain text mode 
    widget->mapToGlobal(QPoint()) returns coordinates of the top-left corner of the widget (in screen coordinates), so you can for example translate it to match right corner of the widget ( as above ).

  3. The following user says thank you to stampede for this useful post:

    chandan (25th February 2011)

Similar Threads

  1. Is the QToolTip::showText Bug?
    By cspp in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2009, 06:12
  2. problem in QTooltip
    By wagmare in forum Qt Programming
    Replies: 8
    Last Post: 6th April 2009, 14:09
  3. QToolTip width
    By Vladimir in forum Qt Programming
    Replies: 7
    Last Post: 3rd March 2007, 08:15
  4. QToolTip
    By suresh in forum Newbie
    Replies: 7
    Last Post: 6th September 2006, 15:00
  5. [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
  •  
Qt is a trademark of The Qt Company.