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
Forum Updated to NodeBB v4.3 + New Features

How to set a png scaled with label

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 355 Views 1 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.
  • S Offline
    S Offline
    sankarapandiyan
    wrote on 21 Nov 2019, 13:09 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

    J 1 Reply Last reply 21 Nov 2019, 13:10
    0
    • S sankarapandiyan
      21 Nov 2019, 13:09

      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

      J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 21 Nov 2019, 13:10 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

      S 1 Reply Last reply 21 Nov 2019, 13:14
      1
      • J jsulm
        21 Nov 2019, 13:10

        @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()));
        
        S Offline
        S Offline
        sankarapandiyan
        wrote on 21 Nov 2019, 13:14 last edited by
        #3

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

        J 1 Reply Last reply 21 Nov 2019, 13:17
        0
        • S sankarapandiyan
          21 Nov 2019, 13:14

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

          J Online
          J Online
          jsulm
          Lifetime Qt Champion
          wrote on 21 Nov 2019, 13:17 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

          S 1 Reply Last reply 21 Nov 2019, 14:34
          1
          • J jsulm
            21 Nov 2019, 13:17

            @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.

            S Offline
            S Offline
            sankarapandiyan
            wrote on 21 Nov 2019, 14:34 last edited by
            #5

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

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 21 Nov 2019, 16:37 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

              3/6

              21 Nov 2019, 13:14

              • Login

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