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 stop an icon from getting stretched?
Forum Updated to NodeBB v4.3 + New Features

How to stop an icon from getting stretched?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 2.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.
  • V Offline
    V Offline
    Vadi2
    wrote on last edited by
    #1

    0_1500668197560_Selection_131.png

    I'd like my icon (borrowed from Qt Creator) to be thin, not the standard 16x16 size. Is there any way to stop it from getting stretched?

    A 1 Reply Last reply
    0
    • V Vadi2

      0_1500668197560_Selection_131.png

      I'd like my icon (borrowed from Qt Creator) to be thin, not the standard 16x16 size. Is there any way to stop it from getting stretched?

      A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      @Vadi2 Call setIconSize() on your QComboBox should constrain it to the size you set as the maximum.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      1
      • V Offline
        V Offline
        Vadi2
        wrote on last edited by
        #3

        @ambershark said in How to stop an icon from getting stretched?:

        setIconSize

        That's weird... says right there that smaller icons are not to be scaled up:

        This size is the maximum size that icons can have; icons of smaller size are not scaled up.

        Yet mine is!

        1 Reply Last reply
        0
        • V Offline
          V Offline
          Vadi2
          wrote on last edited by
          #4

          I'm adding the icon to a QLineEdit by the way, not to the QComboBox.

          The idea didn't work unfortunately:

              auto icon = QIcon(QStringLiteral(":/icons/casesensitively-insensitive.png"));
              qDebug() << "first size:" << icon.availableSizes().first();
              comboBox_searchTerms->setIconSize(icon.availableSizes().first());
          
              auto action = new QAction(icon, tr("Whole Words Only"), this);
              action->setCheckable(true);
              action->setChecked(false);
              lineEdit->addAction(action, QLineEdit::LeadingPosition);
          
          // first size: QSize(8, 16)
          
          A 1 Reply Last reply
          0
          • V Vadi2

            I'm adding the icon to a QLineEdit by the way, not to the QComboBox.

            The idea didn't work unfortunately:

                auto icon = QIcon(QStringLiteral(":/icons/casesensitively-insensitive.png"));
                qDebug() << "first size:" << icon.availableSizes().first();
                comboBox_searchTerms->setIconSize(icon.availableSizes().first());
            
                auto action = new QAction(icon, tr("Whole Words Only"), this);
                action->setCheckable(true);
                action->setChecked(false);
                lineEdit->addAction(action, QLineEdit::LeadingPosition);
            
            // first size: QSize(8, 16)
            
            A Offline
            A Offline
            ambershark
            wrote on last edited by
            #5

            @Vadi2 I don't have the time right now to mess with it and see why so I'll just offer you a hacky solution. Create the icon as a 16x16 but only use 8x16 of it. Then it won't scale since it will be the expected size.

            I'm sure there's a Qt way to control things better but I don't know it off the top of my head and I don't have time to experiment.

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            1 Reply Last reply
            0
            • V Offline
              V Offline
              Vadi2
              wrote on last edited by Vadi2
              #6

              0_1500727667009_Peek 2017-07-22 14-42.gif

              That's what I've done, but it is huge and takes up way too much space. I'm unsatisfied with this.

              1 Reply Last reply
              1
              • C Offline
                C Offline
                Charlie_Hdz
                wrote on last edited by Charlie_Hdz
                #7

                Hi Vadi2,

                As I remember there is a Type (Enum) that defines the fit of Qt Resources in QWidgets. Had you see the documentation completely?

                Kind Regards,
                Enrique Hernandez
                gearstech.com.mx
                chernandez@gearstech.com.mx

                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