PDA

View Full Version : tooltip of slider........



vani.pv
13th September 2012, 13:34
Hi all

Working on Qtcreator for RHEL

Can any body tells me that , How can i get the tool tip for slider.
I have done this.

myslider->setTooltip(QString::number(myslider->sliderposition()),10);

but tooltip is not get into picture while running :(

Thanx.........

wysota
13th September 2012, 16:08
Where did you put this code?

vani.pv
15th September 2012, 09:36
in my form constructor.

wysota
15th September 2012, 13:39
So assuming your slider is initially positioned at 0, you get:


myslider->setTooltip("0");
Isn't that what you get? Doesn't the slider show "0" as its tooltip?

vani.pv
17th September 2012, 09:36
No.Nothing is visible .no t even a 0 value;

wysota
17th September 2012, 10:23
So this doesn't work?


#include <QtGui>

int main(int argc, char **argv) {
QApplication app(argc, argv);
QSlider slider;
slider.setToolTip("tooltip");
slider.show();
return app.exec();
}

vani.pv
24th September 2012, 04:25
No.Its not working.

in my application i have a slider control.

and i wrote some thing like this in my form constructor.

ui->myslider->setposition(10);
ui->myslider0>settooltip("some text");


but its not working.i have tried all possible ways.still not able to fox this problem.

wysota
24th September 2012, 07:30
No.Its not working.

in my application i have a slider control.

I'm not asking about your application. Please run the code I gave you and say whether moving the mouse pointer over the slider makes the tooltip appear or not.

BalaQT
25th September 2012, 10:24
hi vani,


myslider->setTooltip(QString::number(myslider->sliderposition()),10);

There is a mistake in passing the arguments. setToolTip has only one argument.

The correct code will be,

myslider->setTooltip(QString::number(myslider->sliderposition()));

Also there is no need to pass 10 for number function.The default argument is 10

Hope it helps,
Bala

pradeepreddyg95
25th September 2012, 10:47
Add these lines of code it will work .....
connect(ui->horizontalSlider,SIGNAL(sliderMoved(int)),this,SLO T(sliderMoved(int)));

void MainWindow::sliderMoved(int position)
{
ui->horizontalSlider->setToolTip(QString::number(position));
}