1

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.

warunanc
  • 2,221
  • 1
  • 23
  • 40
  • You might find some relevant information [at the question about qlabel showing an image inside a qscrollarea](http://stackoverflow.com/questions/10981662/qlabel-showing-an-image-inside-a-qscrollarea). I have not checked it in details though. – Barney Szabolcs Dec 02 '12 at 23:37
  • i figured it out finally, i eneded up just passing the label image in a new qscrollarea and then just positioning it from there with basic resize and move functions built in to Qt, I LOVE Qt AND ITS SIMPLICITY! – Daniel Moore Dec 04 '12 at 20:47

0 Answers0