Nominate our 2022 Qt Champions!

Scrolling problems

  • Hey,
    i have implemented a widget which has a grid (QTableView object) and two scollbars, one horizontal and one vertical. I have implemented a function that fetches the data to be shown in the grid from a database. I want when the user pressed the arrow from the scroll bar in order to make a single step the application instntly fetch the data. On the contrary when the user scrolls with the whell or move the slider the app don't fetch the data instantly. More specifically i want the data to be fetched when the user stops the slider for some time or releases the slider. For this reason i have used sliderReleased() signal. Moreover, i have write, as a user from this forum suggested, this code for the vertical scrolling actions.

    void handleVTableScrollAction(int action)
        case QAbstractSlider::SliderSingleStepAdd:
        case QAbstractSlider::SliderSingleStepSub:
        case QAbstractSlider::SliderMove:

    the timer is connected to a slot the fetches the data

     connect (&m_Timer, SIGNAL(timeout()), this, SLOT (requestSlot()));

    So my problem is when i wnt to make a single step (by pressing the arrow key) the app don't responds instantly. When i press the arrow for the firtst time nothing seems to be done, but when i am pressing second time the grid follows the movement. All the other movements(wheel and slider move) work fine.

    So i tried to use the valueChange() signal just like this:

      connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(sliderSigleStep()));
      connect(ui->verticalScrollBar, SIGNAL(sliderMoved(int)), this, SLOT(sliderMoveSlot()));

    In this way the single step works fine, but the sliderMoveSlost is never called as the valueChanged singal is always emmited first.

    Is there an explantion for my first issue?
    Can i call a function with the condition that two signals emmited? For example call the sliderMoveSlot only if sliderMove(int) and valueChanged(int) singals emmited and call sliderSingleStep() if only valueChanged(int) is emmited.

Log in to reply