show tooltip when the button is pressed
-
wrote on 1 Aug 2017, 17:01 last edited by
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, 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.wrote on 1 Aug 2017, 17:17 last edited by -
wrote on 1 Aug 2017, 18:21 last edited by
That means one way of achieving this is to use the connect function?
I tried using connect(), but i am probably not using it in the correct manner..connect(ui->Button1,SIGNAL(pressed),SLOT(ui->Button1->setToolTip("This is a 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. -
wrote on 4 Aug 2017, 08:54 last edited by
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
-
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
-
wrote on 4 Aug 2017, 11:10 last edited by Vinod Kuntoji 8 Apr 2017, 11:43
@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);
}
1/7