Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Not able to fix my picture file to Wanted resolution

    General and Desktop
    qpalette qgridlayout qpixmap
    2
    3
    838
    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.
    • H
      houmingc last edited by

      Need to fix a picture to a resolution: 1366 by 254 urgently.
      It's currently maximized to the screen.
      Below is my code. Please kindly pin-point my error.

               QPalette pal=palette();
               pal.setColor(QPalette::Background,Qt::white);
               setPalette(pal);
               setAutoFillBackground(false);
               m_pPalette	= new QPalette();
               m_pPixmap		= new QPixmap(":/file/rightp.png");
               m_pPalette->setBrush(QPalette::Background,QBrush(*m_pPixmap));
               setPalette(*m_pPalette);
               QWidget *centralWidget = new QWidget(this);
               QGridLayout *layout = new QGridLayout();
               centralWidget->setLayout(layout);
      
      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        What about the QImage::scaled function ?

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

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

          Did two thing.

          1. Using recommended code below, compilation Error appear ->"The program has unexpectedly finished"
            QImage myImage;
            myImage.load(":/file/rightp.png");
            myImage.scaled(1366,254, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);

          2. How to scale stylesheet to 1/4 of mainwindow using below code

            MainWindow w;
            w.setStyleSheet("background-image:url(./file/left.png)");
            w.show();

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