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. overwriting inherited stylesheet properties
Forum Updated to NodeBB v4.3 + New Features

overwriting inherited stylesheet properties

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

    I just started learning Qt. It seems that changing inherited stylesheet properties sometimes does not work. The following is the implementation source file for Window class. I have two pointers to QLabel, plabel0 and plabel1, declared in Window.h. plabel0 can change the inherited font size from 40 to 10. However plabel1 cannot change the border width to 0px. I've also tried to set border:none and border-style: 0px for plabel1, but none of these work. I'm using Qt version 5.11.3.

    Window::Window(QWidget * parent)
        : QWidget(parent)
    {
        setFixedSize(400, 400);
        setStyleSheet("background-color: rgb(50,50,50);;");
        setStyleSheet("QLabel {"
                      "font-size: 40px;"
                      "border: 5px solid white};");
        
        plabel0 = new QLabel("ABC", this);
        plabel0->setGeometry(10, 10, 50, 50);
        plabel0->setStyleSheet("font-size: 10px");  // OK
       
        plabel1 = new QLabel("DEF", this);
        plabel1->setGeometry(100, 10, 50, 50);
        plabel1->setStyleSheet("border: 0px"); // does not work
    }
    
    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      Well, works on my 5.12.7.
      How about changing that to:

      "border-width: 0px"
      
      1 Reply Last reply
      0
      • J Offline
        J Offline
        jon-h
        wrote on last edited by
        #3

        I tried that too. Doesn't work.

        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