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");
-
-
@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 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. -
@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);
-
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.