#include #include #include #include #include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget w; { QVBoxLayout *layout = new QVBoxLayout(&w); QLabel *label = new QLabel( "Instructions:\n" "1. Try to scroll the scroll area containing buttons with mouse wheel.\n" "2. Disable buttons clearing the check box right below and try to scroll again. " "When cursor happens to be inside a disabled button it won't scroll with mouse wheel. " "(That is because there is unnecessary QEvent::Wheel case in the switch in QAbstractButton::event() function.)" , &w); label->setWordWrap(true); layout->addWidget(label); QCheckBox *checkBox = new QCheckBox("enable buttons", &w); checkBox->setChecked(true); layout->addWidget(checkBox); QScrollArea *scrollArea = new QScrollArea(&w); layout->addWidget(scrollArea); QWidget *contents = new QWidget(scrollArea); scrollArea->setWidget(contents); scrollArea->setWidgetResizable(true); layout = new QVBoxLayout(contents); const int n = 10; for (int i = 0; iaddWidget(button); } contents->updateGeometry(); } w.resize(240, 320); w.show(); a.exec(); }