PDA

View Full Version : Connect QPushbutton and QListWidget-Scrollbar



BaronVonBullshit
5th November 2015, 10:50
hi,
I'm looking for a Way to connect the Scrollbar of a QListWidget with a QPushbutton. So that I can use two QPushbuttons to scroll up and down. I only find the scrollToTop() and scrollToBottom() functions, but they scroll all the way and I only want them to scroll a Step, like the small Buttons on the Scrollbar.

Thanks in advance!

west
5th November 2015, 11:02
You need to calculate which item should be visible and use QAbstractItemView::scrollTo()

BaronVonBullshit
5th November 2015, 13:41
Thanks for your Answer. Yeah i found this too, but I´m not really happy with it. I was hoping that there is a way to use the triggerActions provided by the slider of the Scrollbar. I mean you can use these Action with your mouse (like "page down" etc.).

Added after 37 minutes:

ok here is the Answer:

void MainView::on_button_up_clicked()
{
ui->listWidget_entries->verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
}