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. The question about the size of QPushButton,maybe about QWidget..
Forum Updated to NodeBB v4.3 + New Features

The question about the size of QPushButton,maybe about QWidget..

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

    Yesterday,i try to product a QPushButton that's very common, I limit QPushButton's size by some funtions.
    setMinimumSize(50,50);
    setMaximumSize(100,100);
    and then I put it on a QWidget by QHBoxLayout.

    When I tretching the QWidget ,the QPushButton also change its size in a certain range(MAX100,MIN50).

    Now the problem is coming....In the initial plan , I want to this QPushButton always keep the spuare,in other words,I hope QPushButton's width always equal QPushButton's height .But in fact ,the QPushButton is always a rectangel in most of time.

    I looking for the answer in internet and QT assistant.QPushButton(mayby QWidget) can return its own width and height alone,but i don't know how to set uo its width and height alone.

    How can i keep it's(QPushButton) width always equal its height when it changes it's size?

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

      Hi,

      It's been a long time but IIRC you can subclass QPushButton and reimplement "heightForWidth":http://doc.qt.io/qt-5/qwidget.html#heightForWidth

      Hope it helps

      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
      0

      • Login

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