開發平台(Platform): (Ex: Win10, Linux, ...)
vs 2015
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
qt5.7
問題(Question):
http://imgur.com/2K3zM0Q
我目前用了QSlier
我想請問有沒有辦法寫額外兩個button去控制pageup and down呢(圖片的紅框處)
(因為Slier的捲軸我之後要隱藏它)
我目前的寫法如下,但這樣要自己去算每個widget的間距 非常麻煩
請問有沒有更好的辦法呢
connect(btnArrowRight, SIGNAL(released()), this, SLOT(moveControllerBox()));
//連結button
void myclass::moveControllerBox() {
QPushButton *btn = qobject_cast<QPushButton *>(sender());
QScrollBar *horizontalScrollBar = listWidget->horizontalScrollBar();
int value = listWidget->horizontalScrollBar()->value();
int movePosition = 0;
if (btn->objectName() == "ArrowLeft") {
if (value - 100 < 0) movePosition = 0;
else movePosition = value - 100;
}
else if (btn->objectName() == "ArrowRight") {
if (value + 100 > 1020) movePosition = 1020;
else movePosition = value + 100;
}
horizontalScrollBar->setSliderPosition(movePosition);
}