Depends if you need those button to be tabs or not. If not, then this should be very easy. Create six buttons and place them in a horizontal layout (you can use a button group to ease your job). The rightmost and leftmost buttons will be used to do the "scrolling" - connect their clicked() signal to a custom slot and in the slot modify the range of numbers displayed. Then connect the button group's clicked() signal to a custom slot and in that slot emit a custom signal with the number of the button clicked (mapped according to the range), for example:
/**
* connected to QButtonGroup::clicked(int)
*/
void wgt::clickedSlot(int c){
emit activated(c+leftmostid);
}
/**
* connected to scroller's clicked()
*/
void wgt::scrollerClicked(){
leftmostid+=sender()==rightScrollButton ? 4 : -4;
updateButtons();
}
void wgt::updateButtons(){
button1
->setText
(QString::number(leftmost
));
button2
->setText
(QString::number(leftmost
+1));
button3
->setText
(QString::number(leftmost
+2));
button4
->setText
(QString::number(leftmost
+3));
}
/**
* connected to QButtonGroup::clicked(int)
*/
void wgt::clickedSlot(int c){
emit activated(c+leftmostid);
}
/**
* connected to scroller's clicked()
*/
void wgt::scrollerClicked(){
leftmostid+=sender()==rightScrollButton ? 4 : -4;
updateButtons();
}
void wgt::updateButtons(){
button1->setText(QString::number(leftmost));
button2->setText(QString::number(leftmost+1));
button3->setText(QString::number(leftmost+2));
button4->setText(QString::number(leftmost+3));
}
To copy to clipboard, switch view to plain text mode
Bookmarks