Results 1 to 5 of 5

Thread: QSlider & QLabel : setText after SIGNAL from QSlider not working

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2011
    Qt products

    Default QSlider & QLabel : setText after SIGNAL from QSlider not working


    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 :

    Qt Code:
    1. /* In the mainFrame constructor ... */
    3. delete choiceBoxB.layout();
    4. choiceBoxBLayout = new QVBoxLayout;
    5. choiceBoxB.setLayout(choiceBoxBLayout);
    6. sliderPosB = new QLabel("100%");
    7. percentageSliderB = new QSlider(Qt::Horizontal);
    8. percentageSliderB->setMinimum(0);
    9. percentageSliderB->setMaximum(200);
    10. percentageSliderB->setSliderPosition(100);
    11. connect(percentageSliderB,SIGNAL(valueChanged(int)),this,SLOT(updateSliderBPos(int)));
    12. choiceBoxBLayout->addWidget(sliderPosB);
    13. choiceBoxBLayout->addWidget(percentageSliderB);
    15. /* ... */
    17. void mainFrame::updateSliderBPos(int value){
    18. sliderPosB->setText(QString("%1%").arg(value));
    19. }
    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,


    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.
    Last edited by Faradn; 28th November 2011 at 21:43.

Similar Threads

  1. Replies: 4
    Last Post: 24th October 2011, 11:00
  2. Problem with QSlider's signal
    By lni in forum Qt Programming
    Replies: 6
    Last Post: 21st September 2011, 19:29
  3. Replies: 7
    Last Post: 15th June 2011, 05:59
  4. QSlider and sliderReleased() signal
    By Luc4 in forum Qt Programming
    Replies: 1
    Last Post: 19th June 2010, 18:37
  5. Replies: 4
    Last Post: 4th March 2010, 11:44


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.