Not able to fix my picture file to Wanted resolution



  • 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);

  • Lifetime Qt Champion

    Hi,

    What about the QImage::scaled function ?



  • 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();


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.