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. Not able to fix my picture file to Wanted resolution

Not able to fix my picture file to Wanted resolution

Scheduled Pinned Locked Moved General and Desktop
qpaletteqgridlayoutqpixmap
3 Posts 2 Posters 1.4k Views 2 Watching
  • 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 Offline
    H Offline
    houmingc
    wrote on last edited by
    #1

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

      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
      0
      • SGaistS SGaist

        Hi,

        What about the QImage::scaled function ?

        H Offline
        H Offline
        houmingc
        wrote on last edited by houmingc
        #3

        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
        0

        • Login

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