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. qlabel border radius stylesheet
QtWS25 Last Chance

qlabel border radius stylesheet

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 5 Posters 35.7k 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.
  • U Offline
    U Offline
    user4592357
    wrote on 12 Dec 2017, 10:45 last edited by
    #1

    i have a qlabel on which i set a stylesheet. all properties work except border-radius: 25px;. i've tried to replace the label with QPushButton but it didn't help, so the problem isn't the label

    T 1 Reply Last reply 12 Dec 2017, 11:07
    0
    • U user4592357
      12 Dec 2017, 10:45

      i have a qlabel on which i set a stylesheet. all properties work except border-radius: 25px;. i've tried to replace the label with QPushButton but it didn't help, so the problem isn't the label

      T Offline
      T Offline
      Taz742
      wrote on 12 Dec 2017, 11:07 last edited by
      #2

      @user4592357
      Can you post how to setStyleSheet in your QLabel ?

      Do what you want.

      1 Reply Last reply
      0
      • U Offline
        U Offline
        user4592357
        wrote on 12 Dec 2017, 11:52 last edited by user4592357 12 Dec 2017, 11:53
        #3
        const auto entryLabel = new QLabel { entryText, this };
        entryLabel->setStyleSheet("margin-left: 10px; border-radius: 25px; background: white; color: #4A0C46;");
        m_pEntriesLayout->addWidget(entryLabel, 0, Qt::AlignCenter);
        
        T J J 3 Replies Last reply 12 Dec 2017, 12:11
        0
        • U user4592357
          12 Dec 2017, 11:52
          const auto entryLabel = new QLabel { entryText, this };
          entryLabel->setStyleSheet("margin-left: 10px; border-radius: 25px; background: white; color: #4A0C46;");
          m_pEntriesLayout->addWidget(entryLabel, 0, Qt::AlignCenter);
          
          T Offline
          T Offline
          Taz742
          wrote on 12 Dec 2017, 12:11 last edited by Taz742 12 Dec 2017, 12:11
          #4

          @user4592357
          its works for me:

              auto entryLabel = new QLabel("My Label");
              entryLabel->setStyleSheet("QLabel{margin-left: 10px; border-radius: 25px; background: red; color: #4A0C46;}");
              ui->gridLayout->addWidget(entryLabel);
          

          https://ibb.co/gYp3cw

          Do what you want.

          1 Reply Last reply
          1
          • U user4592357
            12 Dec 2017, 11:52
            const auto entryLabel = new QLabel { entryText, this };
            entryLabel->setStyleSheet("margin-left: 10px; border-radius: 25px; background: white; color: #4A0C46;");
            m_pEntriesLayout->addWidget(entryLabel, 0, Qt::AlignCenter);
            
            J Offline
            J Offline
            joeQ
            wrote on 12 Dec 2017, 12:11 last edited by
            #5

            @user4592357 Hi,friend. Welcome.

            Try below snippet:

            entryLabel->setStyleSheet("QLabel{margin-left: 10px; border-radius: 25px; background: white; color: #4A0C46;}");
            

            Just do it!

            U 1 Reply Last reply 12 Dec 2017, 12:25
            1
            • J joeQ
              12 Dec 2017, 12:11

              @user4592357 Hi,friend. Welcome.

              Try below snippet:

              entryLabel->setStyleSheet("QLabel{margin-left: 10px; border-radius: 25px; background: white; color: #4A0C46;}");
              
              U Offline
              U Offline
              user4592357
              wrote on 12 Dec 2017, 12:25 last edited by
              #6

              @joeQ i had tried that too.

              @Taz742, doesn't work for me

              i'm placing the label in one of QStackedWidget's widget, which is a member in a QWidget subclass, and on that subclass i set style sheet too. i thought that was the problem, but i added the border-radius part to that style sheet and it still doesn't work

              1 Reply Last reply
              0
              • U user4592357
                12 Dec 2017, 11:52
                const auto entryLabel = new QLabel { entryText, this };
                entryLabel->setStyleSheet("margin-left: 10px; border-radius: 25px; background: white; color: #4A0C46;");
                m_pEntriesLayout->addWidget(entryLabel, 0, Qt::AlignCenter);
                
                J Offline
                J Offline
                J.Hilk
                Moderators
                wrote on 12 Dec 2017, 12:26 last edited by
                #7

                @user4592357
                whats the actuall size of the Label? if its below 50 pxl, no rounded corners will be drawn, also you'll most likly need to specify a border color:

                this for example, works fine for me

                const auto entryLabel = new QLabel { "Blablabla"};
                    entryLabel->setStyleSheet("margin-left: 10px; border: 1px solid black; border-radius: 25px; background: white; color: red;");
                    entryLabel->show();
                    entryLabel->resize(100,100);
                

                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                U 1 Reply Last reply 12 Dec 2017, 12:31
                1
                • J J.Hilk
                  12 Dec 2017, 12:26

                  @user4592357
                  whats the actuall size of the Label? if its below 50 pxl, no rounded corners will be drawn, also you'll most likly need to specify a border color:

                  this for example, works fine for me

                  const auto entryLabel = new QLabel { "Blablabla"};
                      entryLabel->setStyleSheet("margin-left: 10px; border: 1px solid black; border-radius: 25px; background: white; color: red;");
                      entryLabel->show();
                      entryLabel->resize(100,100);
                  
                  U Offline
                  U Offline
                  user4592357
                  wrote on 12 Dec 2017, 12:31 last edited by
                  #8

                  @J.Hilk didn't work for me. and i set no size but the text is long enough (def larger than 50px)

                  J 1 Reply Last reply 12 Dec 2017, 12:35
                  0
                  • U user4592357
                    12 Dec 2017, 12:31

                    @J.Hilk didn't work for me. and i set no size but the text is long enough (def larger than 50px)

                    J Offline
                    J Offline
                    J.Hilk
                    Moderators
                    wrote on 12 Dec 2017, 12:35 last edited by
                    #9

                    @user4592357 height also > 50?


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    U 1 Reply Last reply 12 Dec 2017, 12:37
                    0
                    • J J.Hilk
                      12 Dec 2017, 12:35

                      @user4592357 height also > 50?

                      U Offline
                      U Offline
                      user4592357
                      wrote on 12 Dec 2017, 12:37 last edited by
                      #10

                      @J.Hilk i set (100, 100) as you and didn't get any result

                      J 1 Reply Last reply 12 Dec 2017, 12:39
                      0
                      • U user4592357
                        12 Dec 2017, 12:37

                        @J.Hilk i set (100, 100) as you and didn't get any result

                        J Offline
                        J Offline
                        J.Hilk
                        Moderators
                        wrote on 12 Dec 2017, 12:39 last edited by
                        #11

                        @user4592357 my example was explicitly without parent, for testing purpose.
                        If your label is managed by anything else, a Layout for example, entryLabel->resize(100,100); has quite literly no effect on your label.


                        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                        Q: What's that?
                        A: It's blue light.
                        Q: What does it do?
                        A: It turns blue.

                        U 1 Reply Last reply 12 Dec 2017, 12:42
                        1
                        • J J.Hilk
                          12 Dec 2017, 12:39

                          @user4592357 my example was explicitly without parent, for testing purpose.
                          If your label is managed by anything else, a Layout for example, entryLabel->resize(100,100); has quite literly no effect on your label.

                          U Offline
                          U Offline
                          user4592357
                          wrote on 12 Dec 2017, 12:42 last edited by
                          #12

                          @J.Hilk yes, it's in a layout. so what should i do?

                          M 1 Reply Last reply 12 Dec 2017, 14:25
                          0
                          • U user4592357
                            12 Dec 2017, 12:42

                            @J.Hilk yes, it's in a layout. so what should i do?

                            M Offline
                            M Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on 12 Dec 2017, 14:25 last edited by
                            #13

                            @user4592357
                            You can use label->setMinimumSize(QSize(100,100));

                            U 1 Reply Last reply 12 Dec 2017, 15:10
                            3
                            • M mrjj
                              12 Dec 2017, 14:25

                              @user4592357
                              You can use label->setMinimumSize(QSize(100,100));

                              U Offline
                              U Offline
                              user4592357
                              wrote on 12 Dec 2017, 15:10 last edited by
                              #14

                              @mrjj finally works, thanks!

                              M 1 Reply Last reply 12 Dec 2017, 15:13
                              0
                              • U user4592357
                                12 Dec 2017, 15:10

                                @mrjj finally works, thanks!

                                M Offline
                                M Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on 12 Dec 2017, 15:13 last edited by mrjj 12 Dec 2017, 15:14
                                #15

                                @user4592357
                                Super
                                It also fooled me in the beginning.
                                As soon as a Widget is in a layout, resize or setGeometry have no effect but
                                min/max size and SizePolicy is used instead.

                                1 Reply Last reply
                                2

                                8/15

                                12 Dec 2017, 12:31

                                • Login

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