show tooltip when the button is pressed
-
Hi, I am working on a project that has a lot of buttons on it for each of the different lights that I would be controlling. For each of the light I want to display some information using a tooltip. With the settooltip() command, it doesnt display the tooltip as soon as the button is pressed. It just displays when the mouse is hovered on the button.
Since I am using a touch screen, there wont be any mouse to hover with. Hence please give me some advice on how to display the tooltip when the button is pressed and when the button is released there is no tooltip. -
-
Hi,
Your connect statement is wrong on several levels. Your
SIGNAL
part misses the parenthesis and yourSLOT
statement is just plain wrong. If you want to do it like that, then use a lambda. -
To the below connect statement have one slot for ex:-
public slots:
void catch_and_settooltip(); in .h fileconnect(ui->Button1,SIGNAL(pressed),this,SLOT(catch_and_settooltip()));
void catch_and_settooltip()
{
Button1->setToolTip("This is a tooltip");
}hope this will meet your requirement
-
@jkprog ,
m_Button = new QPushButton("Click"); connect(m_Button,SIGNAL(clicked()),this,SLOT(showToolTip()));
void Widget::showToolTip() {
QToolTip::showText(m_Button->mapToGlobal(QPoint()),"Click",m_Button);
}