How to make a QTool tip show when a button is pressed / clicked
-
hi
#include <QToolTip>QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "tooltip by code");
-
I want to show the tool tip when the button is pressed and it must vanish after some time and again when i press the button it should be popped up. How can this be done ?
-
hi
#include <QToolTip>QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "tooltip by code");
-
@mrjj said in How to make a QTool tip show when a button is pressed / clicked:
#include <QToolTip>
QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "tooltip by code");any sample code will be available so that i can understand better
@ManiRon said in How to make a QTool tip show when a button is pressed / clicked:
@mrjj said in How to make a QTool tip show when a button is pressed / clicked:
#include <QToolTip>
QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "tooltip by code");any sample code will be available so that i can understand better
Isnt that sample code?
-
@ManiRon said in How to make a QTool tip show when a button is pressed / clicked:
@mrjj said in How to make a QTool tip show when a button is pressed / clicked:
#include <QToolTip>
QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "tooltip by code");any sample code will be available so that i can understand better
Isnt that sample code?
-
@Pl45m4 sorry i applied it at wrong place , Now it worked fine . but it just shows for some mili seconds i think so , Can we increase the display time of tool tip ?
@Pl45m4 said in How to make a QTool tip show when a button is pressed / clicked:
The showText-function also contains a timeout-parameter
https://doc.qt.io/qt-5/qtooltip.html#showText-2void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect, int msecDisplayTime)
If you set msecDisplayTime to e.g. 3000, it will stay visible for 3 seconds
-
@Pl45m4 said in How to make a QTool tip show when a button is pressed / clicked:
The showText-function also contains a timeout-parameter
https://doc.qt.io/qt-5/qtooltip.html#showText-2void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect, int msecDisplayTime)
If you set msecDisplayTime to e.g. 3000, it will stay visible for 3 seconds
-
@Pl45m4 said in How to make a QTool tip show when a button is pressed / clicked:
The showText-function also contains a timeout-parameter
https://doc.qt.io/qt-5/qtooltip.html#showText-2void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect, int msecDisplayTime)
If you set msecDisplayTime to e.g. 3000, it will stay visible for 3 seconds
-
@ManiRon said in How to make a QTool tip show when a button is pressed / clicked:
the tool tip is not showing till what ever time i have specified ?
What do you mean? You want to have a delay before showing the tool tip? If so then why not using QTimer?
-
-
Hi
Works on linux and windows for me. (Qt 5.9)
it stays the time you tell it.
Do note however, you CANNOT click on the screen in the meantime. then it goes away at once. -
Check your parameters... you have no Text-parameter there...
QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), "MY_TOOLTIP", qTable, rect,3000);
What is qTable in your case?
-
Hi
Works on linux and windows for me. (Qt 5.9)
it stays the time you tell it.
Do note however, you CANNOT click on the screen in the meantime. then it goes away at once. -
Hi
Works on linux and windows for me. (Qt 5.9)
it stays the time you tell it.
Do note however, you CANNOT click on the screen in the meantime. then it goes away at once.@mrjj it display the tool tip only for few milli seconds , is there something wrong i am doing ?
QRect rect; rect.setHeight(ui->pushbtn->height()); rect.setWidth(ui->pushbtn->width()); QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), qTable,ui->pushbtn,rect,5000);
-
@ManiRon said in How to make a QTool tip show when a button is pressed / clicked:
the tool tip is not showing till what ever time i have specified ?
What do you mean? You want to have a delay before showing the tool tip? If so then why not using QTimer?
-
Maybe related to https://bugreports.qt.io/browse/QTBUG-18520
-
Maybe related to https://bugreports.qt.io/browse/QTBUG-18520
QRect rect; rect.setHeight(ui->pushbtn->height()); rect.setWidth(ui->pushbtn->width()); this->setToolTipDuration(5000); QToolTip::showText( this->mapToGlobal( QPoint( 0, 0 ) ), qTable,this,rect,5000);
tried something like this but no change
-
Hi
What Qt version are you using?
It works for me with Qt5.9/5.13 on Windows and Linux.