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 can i use round buttons and put the in a layout without lose their shape
Forum Updated to NodeBB v4.3 + New Features

how can i use round buttons and put the in a layout without lose their shape

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 674 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.
  • G Offline
    G Offline
    Giakara
    wrote on last edited by
    #1

    Screenshot_54.png
    Screenshot_55.png

    also is there a better way to create round buttons?

    M A 2 Replies Last reply
    0
    • G Giakara

      Screenshot_54.png
      Screenshot_55.png

      also is there a better way to create round buttons?

      M Offline
      M Offline
      mpergand
      wrote on last edited by mpergand
      #2

      @Giakara
      You need to set them a fixed size,
      or to define a prefered one by implementing :
      virtual QSize sizeHint() const

      also is there a better way to create round buttons?

      Better way than what ?

      [EDIT] In fact I don't understand the question, because putting a widget in a layout can only change its size not its shape ...

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Giakara
        wrote on last edited by
        #3

        y sorry i used this code
        QPushButton {
        color: #333;
        border: 2px solid #555;
        border-radius: 20px;
        border-style: outset;
        background: qradialgradient(
        cx: 0.3, cy: -0.4, fx: 0.3, fy: -0.4,
        radius: 1.35, stop: 0 #fff, stop: 1 #888
        );
        padding: 5px;
        }

        QPushButton:hover {
        background: qradialgradient(
        cx: 0.3, cy: -0.4, fx: 0.3, fy: -0.4,
        radius: 1.35, stop: 0 #fff, stop: 1 #bbb
        );
        }

        1 Reply Last reply
        0
        • G Giakara

          Screenshot_54.png
          Screenshot_55.png

          also is there a better way to create round buttons?

          A Offline
          A Offline
          anil_arise
          wrote on last edited by
          #4

          @Giakara with set fixed size, example:

          for(int i=0;i<3;i++)
          {
          QPushButton * button = new QPushButton;
          button->setText(QString::number(i+1));
          button->setFixedSize(100,100);
          QRect rect(QPoint(), button->size());
          rect.adjust(10, 10, -10, -10);
          QRegion region(rect,QRegion::Ellipse);
          button->setMask(region);
          horizontalLayout->addWidget(button);
          }

          1 Reply Last reply
          0
          • B Offline
            B Offline
            Bonnie
            wrote on last edited by Bonnie
            #5

            Your border-radius is set to 20px, that need your buttons to have both their width and height at least 40px to work.
            It has nothing to do with layouts.

            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