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. Qt How to prevent child QDialogs or QWidgets from inheriting parent StyleSheet

Qt How to prevent child QDialogs or QWidgets from inheriting parent StyleSheet

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.7k 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.
  • B Offline
    B Offline
    BAHRAMUDIN ADIL
    wrote on last edited by
    #1

    I am having trouble with style inheriting in Qt. It makes me a lot of problems and it really is a very headache.
    I have QWidet which I set the background 30% transparent black inside has a button which when clicked will open a custom QDialog or QMessageBox, but when the dialog opens, it is all black and very ugly, it has inherited the parent style. And also when I make a parent QWidget border to a custom one, then all the components inside this QWidget get the same border style even CheckBoxes or QButtons, and so on. It is something very big problem which while you want to give a custom style to the QWidgets.

    How to solve! Thanks!

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You can narrow down style definition to a single class (or even a single object)

      • https://doc.qt.io/qt-5/stylesheet-syntax.html#conflict-resolution
      • additional options listed in https://doc.qt.io/qt-5/stylesheet-reference.html

      If you want to stop subwidgets from inheriting the style, call setStyleSheet("") on widgets which should have default style sheet.

      (Z(:^

      1 Reply Last reply
      4
      • B Offline
        B Offline
        BAHRAMUDIN ADIL
        wrote on last edited by
        #3

        Thanks, the narrowing down works. But setStyleSheet("") still not working.

        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