Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Inbuilt QSlider functions value() and valueChanged(int) do not return the same result
Forum Updated to NodeBB v4.3 + New Features

Inbuilt QSlider functions value() and valueChanged(int) do not return the same result

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kidow
    wrote on last edited by
    #1

    Hey guys,

    I'm pretty new to Qt, so I hope my questions won't be that stupid.
    I'm trying to write a small program, which should be able to convert one colorspace into another. I was trying to realize that with sliders.What I have are three sliders for RGB and maybe for example three sliders for CMY.

    I want to be able to move one slider (for example R), get the values of the other two (for example GB) -> convert them -> set the Slider values of CMY.

    What I realized was that the inbuilt QSlider functions value() and valueChanged(int) do not return the same result.

    In code, this means
    SIGNAL and SLOT Stuff
    @connect(ui->rSlide, SIGNAL(sliderMoved(int)), this, SLOT(getSliderValues()));
    connect(ui->gSlide, SIGNAL(sliderMoved(int)), this, SLOT(getSliderValues()));
    connect(ui->bSlide, SIGNAL(sliderMoved(int)), this, SLOT(getSliderValues()));@

    GetSliderValues()
    @int MainWindow::getSliderValues()
    {
    red = ui->rSlide->value();
    green = ui->gSlide->value();
    blue = ui->bSlide->value()
    }@

    Does not return the same Slider result then
    @connect(ui->rSlide, SIGNAL(sliderMoved(int)), this, SLOT(convertFromRGB(int)));
    connect(ui->gSlide, SIGNAL(sliderMoved(int)), this, SLOT(convertFromRGB(int)));
    connect(ui->bSlide, SIGNAL(sliderMoved(int)), this, SLOT(convertFromRGB(int)));@

    ConvertFromRGB(int)
    @void MainWindow::convertFromRGB(int test)
    {
    cout << test << endl;
    }@

    Both Versions return a different result, they differ by 2.
    Did you guys ever stumble upon something like that? Or could you tell me if I'm doing something wrong? Because I would really like to implement the first version.

    Thanks for all your time and in advance for the answers.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Pretty strange indeed, can you check whether the slider has mouse tracking enabled ? If not, the difference is normal, otherwise there's something wrong.

      In any case, the valueChanged signal seems more suited to your purpose.

      Also, what combo of Qt/OS/Compiler are you using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved