I'm working on getting this QLabel
image I set up that is working perfectly fine. I just need to get it to scroll. I understand the QScrollArea
setup but this is not the typical use of QScrollArea
.
I need to set up my scroll area in the mainwindow.cpp
alongside my QLabel
. This is the area where I set up my QLabel
and where I want to set it up to be able to be scrollable.
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QString filename = "C:/Users/SOYO/Desktop/Qt_GUI_C++/ParkOur/map.jpg";
QImage image(filename);
ui->labelMap->setPixmap(QPixmap::fromImage(image));
QScrollArea *scrollArea = new QScrollArea;
scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(ui->labelMap);
}
I don't know how to get QScrollArea
to work without it taking complete control over the entire program and showing all the image.
I just need the image to be scrollable, and please give me example code, it makes everything much easier to grasp. Thank you in advance for your assistance.
P.S. I do not want the scroll to be over the main widget, just the QLabel
widget with the image in it.