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 set a png scaled with label

How to set a png scaled with label

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

    QPixmap wifi(":/wifi-icon-6.png");
    ui->label->setPixmap(wifi);
    ui->label->show();
    ui->wifi->setScaledSize(ui->label->size());// This one leads to Error

    Say me some suggestions to set up this scaling

    jsulmJ 1 Reply Last reply
    0
    • sankarapandiyanS sankarapandiyan

      QPixmap wifi(":/wifi-icon-6.png");
      ui->label->setPixmap(wifi);
      ui->label->show();
      ui->wifi->setScaledSize(ui->label->size());// This one leads to Error

      Say me some suggestions to set up this scaling

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @sankarapandiyan Please read documentation - there is no setScaledSize method.
      https://doc.qt.io/qt-5/qpixmap.html#scaled

      QPixmap wifi(":/wifi-icon-6.png");
      ui->label->show();
      ui->label->setPixmap(wifi.scaled(ui->label->size()));
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      sankarapandiyanS 1 Reply Last reply
      1
      • jsulmJ jsulm

        @sankarapandiyan Please read documentation - there is no setScaledSize method.
        https://doc.qt.io/qt-5/qpixmap.html#scaled

        QPixmap wifi(":/wifi-icon-6.png");
        ui->label->show();
        ui->label->setPixmap(wifi.scaled(ui->label->size()));
        
        sankarapandiyanS Offline
        sankarapandiyanS Offline
        sankarapandiyan
        wrote on last edited by
        #3

        @jsulm ui->label->setScaledContents(true);
        ui->label->setPixmap(QPixmap::fromImage(wifi));I Got it finally Is It correct >??

        jsulmJ 1 Reply Last reply
        0
        • sankarapandiyanS sankarapandiyan

          @jsulm ui->label->setScaledContents(true);
          ui->label->setPixmap(QPixmap::fromImage(wifi));I Got it finally Is It correct >??

          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @sankarapandiyan said in How to set a png scaled with label:

          I Got it finally Is It correct

          Looks like it is. But now you do not scale.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          sankarapandiyanS 1 Reply Last reply
          1
          • jsulmJ jsulm

            @sankarapandiyan said in How to set a png scaled with label:

            I Got it finally Is It correct

            Looks like it is. But now you do not scale.

            sankarapandiyanS Offline
            sankarapandiyanS Offline
            sankarapandiyan
            wrote on last edited by
            #5

            @jsulm Yes ..I understood ..Thanks a lot

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

              Hi,

              Depending on what you need, the scaledContent property might be of interest.

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

              1 Reply Last reply
              1

              • Login

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