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 fix QButton weird outline
Qt 6.11 is out! See what's new in the release blog

How to fix QButton weird outline

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 1.5k 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.
  • ahsan737A Offline
    ahsan737A Offline
    ahsan737
    wrote on last edited by ahsan737
    #1

    I am working on mobile app GUI before it was fine but then some error occurred and buttons start displaying weird outlines as shown in the picture (below). Actually, this has happened when I have merged this code in my application. He has created GUI in QML, but my previous app was Qwidget based so I have translated the QML code to CPP. but when I build and deploy the app then GUI shows this behavior (buttons started showing outlines.). It is working as it should, but even flat buttons are now showing traces. I also have removed settings related to QML. How can I fix it?

    0_1567388394480_Untitled-3_1.jpg

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

      Hi,

      You should show the code you used to create this button.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      ahsan737A 1 Reply Last reply
      1
      • ahsan737A Offline
        ahsan737A Offline
        ahsan737
        wrote on last edited by
        #3

        I have placed these buttons in QtCreator and then set some parameters with code.

            //set the button color+text+background
            QFont Buttonfont("SimSun",disp_size.applyFontRatio(10),QFont::Normal, Qt::AlignCenter);
            ui->pushButton_startScreen->setFont(Buttonfont);
            ui->pushButton_startScreen->setMinimumSize(disp_size.applyRatio(250),disp_size.applyRatio(75));
            ui->pushButton_startScreen->setStyleSheet("color: rgb(255, 255, 255);background-color: rgb(0, 60, 127);");
            ui->pushButton_startScreen->setText("START");
        
        J.HilkJ 1 Reply Last reply
        0
        • ahsan737A ahsan737

          I have placed these buttons in QtCreator and then set some parameters with code.

              //set the button color+text+background
              QFont Buttonfont("SimSun",disp_size.applyFontRatio(10),QFont::Normal, Qt::AlignCenter);
              ui->pushButton_startScreen->setFont(Buttonfont);
              ui->pushButton_startScreen->setMinimumSize(disp_size.applyRatio(250),disp_size.applyRatio(75));
              ui->pushButton_startScreen->setStyleSheet("color: rgb(255, 255, 255);background-color: rgb(0, 60, 127);");
              ui->pushButton_startScreen->setText("START");
          
          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @ahsan737
          ui->pushButton_startScreen->setStyleSheet("color: rgb(255, 255, 255);background-color: rgb(0, 60, 127);outline:none;");


          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.

          ahsan737A 1 Reply Last reply
          1
          • SGaistS SGaist

            Hi,

            You should show the code you used to create this button.

            ahsan737A Offline
            ahsan737A Offline
            ahsan737
            wrote on last edited by ahsan737
            #5

            @sgaist Actually I have merged this code in my application. He has created GUI in QML, but my previous app was Qwidget based so I have translated the QML code to CPP. but when I build and deploy the app then GUI shows this behavior (buttons started showing outlines.). It is working as it should, but even flat buttons are now showing traces. I also have removed settings related to QML.

            1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @ahsan737
              ui->pushButton_startScreen->setStyleSheet("color: rgb(255, 255, 255);background-color: rgb(0, 60, 127);outline:none;");

              ahsan737A Offline
              ahsan737A Offline
              ahsan737
              wrote on last edited by ahsan737
              #6

              @j-hilk I have tried this but it hasn't worked for me. still, QPushbuttons are looking unusual.
              they are supposed to look like this (picture is shown in the problem description).

              J.HilkJ 1 Reply Last reply
              0
              • ahsan737A ahsan737

                @j-hilk I have tried this but it hasn't worked for me. still, QPushbuttons are looking unusual.
                they are supposed to look like this (picture is shown in the problem description).

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @ahsan737 it should work, and it did for me.

                Do you have a parent/global stylsheet that is applied?
                I would suggest creating a basic ui in a new project and see if you can recreate the issue and if applying outline:none does something or not.


                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.

                ahsan737A 1 Reply Last reply
                1
                • J.HilkJ J.Hilk

                  @ahsan737 it should work, and it did for me.

                  Do you have a parent/global stylsheet that is applied?
                  I would suggest creating a basic ui in a new project and see if you can recreate the issue and if applying outline:none does something or not.

                  ahsan737A Offline
                  ahsan737A Offline
                  ahsan737
                  wrote on last edited by ahsan737
                  #8

                  @j-hilk okay sir, I will try it. I haven't applied global/parent stylesheet.

                  1 Reply Last reply
                  0
                  • ahsan737A Offline
                    ahsan737A Offline
                    ahsan737
                    wrote on last edited by
                    #9

                    the issue is resolved using the following line in main.cpp file:

                    QApplication::setStyle(QStyleFactory::create("windows"));
                    
                    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