Hi,
As the title states, I have some issues with a QSlider/QLabel connection.
I simply want to show the slider's position in a label as a text and update it every time the slider is changed (and all this in a QMessageBox).
Here's the failing code :
/* In the mainFrame constructor ... */
delete choiceBoxB.layout();
choiceBoxB.setLayout(choiceBoxBLayout);
sliderPosB
= new QLabel("100%");
percentageSliderB
= new QSlider(Qt
::Horizontal);
percentageSliderB->setMinimum(0);
percentageSliderB->setMaximum(200);
percentageSliderB->setSliderPosition(100);
connect(percentageSliderB,SIGNAL(valueChanged(int)),this,SLOT(updateSliderBPos(int)));
choiceBoxBLayout->addWidget(sliderPosB);
choiceBoxBLayout->addWidget(percentageSliderB);
/* ... */
void mainFrame::updateSliderBPos(int value){
sliderPosB
->setText
(QString("%1%").
arg(value
));
}
/* In the mainFrame constructor ... */
delete choiceBoxB.layout();
choiceBoxBLayout = new QVBoxLayout;
choiceBoxB.setLayout(choiceBoxBLayout);
sliderPosB = new QLabel("100%");
percentageSliderB = new QSlider(Qt::Horizontal);
percentageSliderB->setMinimum(0);
percentageSliderB->setMaximum(200);
percentageSliderB->setSliderPosition(100);
connect(percentageSliderB,SIGNAL(valueChanged(int)),this,SLOT(updateSliderBPos(int)));
choiceBoxBLayout->addWidget(sliderPosB);
choiceBoxBLayout->addWidget(percentageSliderB);
/* ... */
void mainFrame::updateSliderBPos(int value){
sliderPosB->setText(QString("%1%").arg(value));
}
To copy to clipboard, switch view to plain text mode
Every variable or object or class has been declared in the header file (no compiling issues).
For some reason I don't understand, it worked almost fine once but I couldn't find out what was not working, that wasn't enough.
The purpose of the slider and the label is to allow user to choose a percentage to change the brightness of an image (project in an image editor).
Thanks for your help,
Faradn
UPDATE :
I forgot to mention that the input text is perfectly fine (tested with std::cout) and that the signal works fine too. It is the setText that is not working properly.
Bookmarks