Results 1 to 9 of 9

Thread: problem in QTooltip

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    658
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default problem in QTooltip

    hi friends,
    i am having a window with size (10,800,1010,40) .. its having a button (diagnosButton) ... a thread is running parallel which will receive communication from server and emit a signal newMessage (QString) ... in my mainwindow i get the signal of thread and called a slot ()
    this is the slot
    Qt Code:
    1. void TidBar::showToolTip(const QString &message)
    2. {
    3. QFont serifFont("Times", 12, QFont::Bold);
    4. QPalette color;
    5. int setval = 0;
    6. color.setColor( QPalette::Inactive,QPalette::QPalette::ToolTipBase,Qt::yellow);
    7. //value = diagnosButton->mapToGlobal(diagnosButton->rect().topLeft());
    8. value = diagnosButton->mapToGlobal(QPoint(0, 0));
    9. qreal x = value.x();
    10. qreal y = value.y();
    11. QRect rectval = this->rect();
    12. QPoint value2 (x + 70, y - 54);
    13.  
    14. QToolTip::setPalette(color);
    15. QToolTip::setFont(serifFont);
    16. QToolTip::showText(value2, message,this ,rectval );
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 
    i try to show a tooltip with the message from the thread signal newMessage(QString) .... i thought this tooltip will last for long until i move the cursor outside the window ...
    but the tooltip disapper or hide afer few seconds .... i dont know where i mistaked .... please help

  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: problem in QTooltip

    QToolTip has a default timeout of 10 seconds.
    There are 2 ways you can display it longer -
    1) Easy way : Use ur timer of say 5 sec, and show tooltip every 5 sec.. u can code logic when to quit

    2) harder way : make your custom widget, override the tooltip event, and display your custom tooltip. You can close it on lost focus.

    second way might be better..

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

    wagmare (6th April 2009)

  4. #3
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in QTooltip

    umm..i'll say that instead of creating a custom widget and handling its tooltip event, you could go ahead and make a custom TOOLTIP itself..its just like creating a custom widget, just set the window flag to be Qt::tooltip..here is how u should go about it:

    1. have the constructor take the heading and tooltip strings..put those in layouts..also include a close button so that it depends on user when to close the tooltip..or you could also have a timer started in there itself..as ur requirement may be

    2. have a function in it like showTooltip(QWidget *parent,...), here parent would be the widget u need to show the tooltip on..u can use the code u wrote earlier to find the position where to show the tooltip on.

    3. u can also add functions to show the tooltip on right/left of parent, thus giving you good control over everything.

    And when u think about it, its very easy to make, about 2-3 hours work..other details are easy to figure out

  5. The following user says thank you to talk2amulya for this useful post:

    wagmare (6th April 2009)

  6. #4
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    658
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in QTooltip

    thanks to both mr.Aamer and madam.Amulya... sorry for the late reply .... i will follow your suggestion and soon reply ... thanks

  7. #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: problem in QTooltip

    Sorry to interrupt,
    but I guess its Mr. Amulya, or Madam

  8. #6
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in QTooltip

    whoa , how did you i got a sex change operation?

  9. #7
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    658
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in QTooltip

    my mistake ... from your name i thought u are an intelligent lady .... are u male or female ...?

  10. #8
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in QTooltip

    why do you still have doubts that i m a hunky-dunky male

  11. #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: problem in QTooltip

    Now am confused... cant u reply in a clear way

Similar Threads

  1. Very strange socket programming problem
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2008, 12:05
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. problem with paint and erase in frame
    By M.A.M in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2008, 20:17
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.