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. pixmap resize

pixmap resize

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 306 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.
  • I Offline
    I Offline
    IknowQT
    wrote on last edited by
    #1

    9d61386a-08a3-4a63-9878-15e8fd339fd7-image.png

    Draw a chart and get a pixmap with chartview->grab().
    Then, I want to expand the chart to fit the label, but I can't get a full screen. And the resolution is broken... Help me.

            this->ui.label_13->setAlignment(Qt::AlignCenter);
    	this->ui.label_13->setFrameShape(QFrame::Box);
    	this->ui.label_13->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    	this->ui.label_13->setBackgroundRole(QPalette::Base);
    	this->ui.label_13->setAutoFillBackground(true);
    	this->ui.label_13->setMinimumSize(132, 132);
    
    
    void QReportForm::SetChartPixmap(QPixmap* pix)
    {
    	m_pPixmap = pix;
    	this->ui.label_13->setPixmap(
    		pix->scaled(
    			this->ui.label_13->width(),
    			this->ui.label_13->height(),
    			Qt::KeepAspectRatio)
    	);
    }
    
    
    eyllanescE 1 Reply Last reply
    0
    • I IknowQT

      9d61386a-08a3-4a63-9878-15e8fd339fd7-image.png

      Draw a chart and get a pixmap with chartview->grab().
      Then, I want to expand the chart to fit the label, but I can't get a full screen. And the resolution is broken... Help me.

              this->ui.label_13->setAlignment(Qt::AlignCenter);
      	this->ui.label_13->setFrameShape(QFrame::Box);
      	this->ui.label_13->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
      	this->ui.label_13->setBackgroundRole(QPalette::Base);
      	this->ui.label_13->setAutoFillBackground(true);
      	this->ui.label_13->setMinimumSize(132, 132);
      
      
      void QReportForm::SetChartPixmap(QPixmap* pix)
      {
      	m_pPixmap = pix;
      	this->ui.label_13->setPixmap(
      		pix->scaled(
      			this->ui.label_13->width(),
      			this->ui.label_13->height(),
      			Qt::KeepAspectRatio)
      	);
      }
      
      
      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      @IknowQT

      1. It is unnecessary to use pointers for QPixmap so change to:
      void QReportForm::SetChartPixmap(const QPixmap & pix)
      {
          ui.label_13->setPixmap(pix);
      }
      
      1. Use the scaledContents property: ui.label_13->setScaledContents(true);

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      1
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #3

        you generate svg image to fit the full screen without losing resolution. Do not create pixmap.
        https://doc.qt.io/qt-5/qtsvg-svggenerator-example.html

        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