Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to scale the background image for the Mainwindow
QtWS25 Last Chance

how to scale the background image for the Mainwindow

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.4k Views
  • 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.
  • ManiRonM Offline
    ManiRonM Offline
    ManiRon
    wrote on last edited by
    #1

    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
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • ManiRonM Offline
        ManiRonM Offline
        ManiRon
        wrote on last edited by
        #3

        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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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

          ManiRonM 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            What type of widget is your MainWindow ?

            ManiRonM Offline
            ManiRonM Offline
            ManiRon
            wrote on last edited by
            #5

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

            MainWindow

            I used QT WIdget application type

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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

              ManiRonM 1 Reply Last reply
              0
              • SGaistS SGaist

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

                ManiRonM Offline
                ManiRonM Offline
                ManiRon
                wrote on last edited by
                #7

                @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
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved