QScrollArea is a widget in the Qt GUI toolkit that provides a scrollable viewport for displaying content that is larger than the size of the widget itself. The setAlignment function of QScrollArea is used to set the alignment of the widget within the scroll area.
Example #1:
QScrollArea *scrollArea = new QScrollArea(); scrollArea->setAlignment(Qt::AlignCenter); scrollArea->setWidgetResizable(true);
In this example, a QScrollArea object is created and the setAlignment function is used to set the alignment to center. The setWidgetResizable function sets the widget within the scroll area to be resizable.
Example #2:
QGridLayout *grid = new QGridLayout(); QWidget *scrollWidget = new QWidget(); scrollWidget->setLayout(grid); QScrollArea *scrollArea = new QScrollArea(); scrollArea->setWidget(scrollWidget); scrollArea->setAlignment(Qt::AlignRight);
In this example, a QGridLayout is created and set to a QWidget. The QWidget is then set to be the widget for the QScrollArea using the setWidget function. The setAlignment function is then used to set the alignment to the right.
Package library: Qt GUI toolkit
C++ (Cpp) QScrollArea::setAlignment - 18 examples found. These are the top rated real world C++ (Cpp) examples of QScrollArea::setAlignment extracted from open source projects. You can rate examples to help us improve the quality of examples.