Qt Forum

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

    Call for Presentations - Qt World Summit

    Unsolved how to scale the background image for the Mainwindow

    General and Desktop
    3
    7
    835
    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.
    • ManiRon
      ManiRon last edited by

      I want to scale the image . (i.e) I want to place the image as the size of the Mainwindow when its in minimized size and resize the image when the Mainwindow widget is maximized .

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        Hi
        What have you tried so far?
        How did you set the background image on mainwindow in the first place?
        There is an event for when resize happen which you can use.
        http://doc.qt.io/qt-5/qwidget.html#resizeEvent

        1 Reply Last reply Reply Quote 0
        • ManiRon
          ManiRon last edited by

          QPixmap bkgnd("" + QDir::currentPath() + "./InputFiles/Images/Logo.png");
          bkgnd = bkgnd.scaled(this->window()->size(), Qt::IgnoreAspectRatio);
          QPalette palette;
          palette.setBrush(QPalette::Background, bkgnd);
          this->setPalette(palette);

          My Current Code

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Hi,

            What type of widget is your MainWindow ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            ManiRon 1 Reply Last reply Reply Quote 0
            • ManiRon
              ManiRon @SGaist last edited by

              @SGaist said in how to scale the background image for the Mainwindow:

              MainWindow

              I used QT WIdget application type

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                In other words, the question was: what is the base class of MainWindow ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                ManiRon 1 Reply Last reply Reply Quote 0
                • ManiRon
                  ManiRon @SGaist last edited by

                  @SGaist
                  class MainWindow : public QMainWindow is this the one. Or if i am saying it wrong kindly mention how to see it.

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