I've implemented the sidebar using empty widget and several pushbuttons styled with stylesheets:
- layout widget vertically
- all buttons are checkable
- last button is disabled and its vertical size policy is set to 'expanding' and it contains no text (its role is to decorate sidebar)
- implemented rules for QPushButton normal state and 'hover', 'checked', 'disabled' pseudo-classes
And there is no icons in sidebar...
Also I created function to make sure that only one of the buttons is checked:
void MainWindow
::switchButtons(QPushButton *b
) { // called when button is clicked if (b != selectedButton) {
selectedButton->setChecked(false);
selectedButton = b;
}
else
selectedButton->setChecked(true);
}
void MainWindow::switchButtons(QPushButton *b) { // called when button is clicked
if (b != selectedButton) {
selectedButton->setChecked(false);
selectedButton = b;
}
else
selectedButton->setChecked(true);
}
To copy to clipboard, switch view to plain text mode
x.png
Bookmarks