Solved Value from the "ScrollBar" for "switch"
-
Hi!
How to get value from the scroll bar for switch?oid MainWindow::on_pushButton_clicked() { ui->horizontalScrollBar->setRange(0, 8); switch(ui->horizontalScrollBar->value()){ case ui->horizontalScrollBar->value(1): { } case ui->horizontalScrollBar->value(2): { } }
-
Hi.
case
labels take constant expressions, so simply:switch(ui->horizontalScrollBar->value()) { case 1: { } case 2: { } }
Don't forget to put
break;
between those cases so you don't accidentaly fall through. -
Hi.
case
labels take constant expressions, so simply:switch(ui->horizontalScrollBar->value()) { case 1: { } case 2: { } }
Don't forget to put
break;
between those cases so you don't accidentaly fall through.