Question

Recently, I've been doing some work on a personal project. The thing is that now, I need to create a widget with the scroll bars in a mainWindow.
But i do not know how!!! Please help me!

Was it helpful?

Solution

You can use QScrollArea which provides a scrolling view onto another widget. It is used to display the contents of a child widget within a frame. If the widget exceeds the size of the frame, the view can provide scroll bars so that the entire area of the child widget can be viewed.

An example:

 QLabel *imageLabel = new QLabel;
 QImage image("happyguy.png");
 imageLabel->setPixmap(QPixmap::fromImage(image));

 QScrollArea *scrollArea = new QScrollArea(this);
 scrollArea->setBackgroundRole(QPalette::Dark);
 scrollArea->setWidget(imageLabel);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top