QScrollBar *scrollBar = new QScrollBar(Qt::Horizontal); scrollBar->setMaximum(100);
QScrollBar *scrollBar = new QScrollBar(Qt::Vertical); scrollBar->setMaximum(200);
QScrollBar *scrollBar = new QScrollBar(Qt::Vertical); scrollBar->setMaximum(300); int max_value = scrollBar->maximum();In this example, a Vertical QScrollBar is created, and its maximum value is set to 300 using the setMaximum() method. The maximum value is then retrieved using the maximum() method and stored in an integer variable. Package Library: Qt Core and Qt GUI Overall, QScrollBar is a useful widget that offers a range of functionalities, including controlling the maximum value of the scroll bar. It is a part of the Qt GUI toolkit and is included in the Qt Core and Qt GUI packages.