Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [SOLVED] How to shrink QMainWindow with a QLabel including an image?

    General and Desktop
    2
    3
    2106
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      RolBri last edited by RolBri

      Hi,
      I am using several QLabels for displaying videos in my MainWindow.
      Now I have a problem with re-sizing the window.
      I can easily use my mouse to make the MainWindow bigger while the program executes.
      All the videos are automatically resized using the code below.
      But if I try to make the window smaller it is not working.
      It looks like the QLabels cannot be resized to a smaller size.

      What can I do that the user is able to make the MainWindow bigger and also smaller?

      Thank you very much :-)

      void MainWindow::updateGuiVid1(QImage img)
      {
          if (!img.isNull())
          {
              ui->video1_lbl->setAlignment(Qt::AlignCenter);
              ui->video1_lbl->setPixmap(QPixmap::fromImage(img).scaled(ui->video1_lbl->size(),Qt::KeepAspectRatio,Qt::FastTransformation));
          }
      }
      
      1 Reply Last reply Reply Quote 1
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        hi
        have you tried with
        label->setMinimumSize(1, 1)

        1 Reply Last reply Reply Quote 1
        • R
          RolBri last edited by

          Sorry for the late reply, I was away for a while.

          Actually your suggestion works perfect :-)

          Thank you very much!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post