Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Set QFrame frame style with QSS
Qt 6.11 is out! See what's new in the release blog

Set QFrame frame style with QSS

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 123 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.
  • N Offline
    N Offline
    Neph
    wrote last edited by
    #1

    Hi,

    I (Qt 5.15.13 and Python 3.12.12) am currently working on a layout that uses a QFrame to create a border around another layout or a line between two layouts.

    I know that you can set the design of the QFrame, as shown in the image in the documentation with e.g. qframe.setFrameStyle(QFrame.Box | QFrame.Plain) and the border's thickness with qframe.setLineWidth(3).

    I also know that you can alternatively use QSS to set the border thickness and even the color:

    qframe.setStyleSheet("QFrame#myqframe {border: 1px solid red}")
    

    Now I'm wondering: Is it also possible to set the actual frame style using only QSS? I tried this but it didn't work (didn't display anything):

    qframe.setStyleSheet(
    "QFrame#myqframe {"
        "frameShape: box;"
        "frameShadow: raised"
        "border: 3px solid black"
    "}")
    
    JonBJ 1 Reply Last reply
    0
    • N Neph

      Hi,

      I (Qt 5.15.13 and Python 3.12.12) am currently working on a layout that uses a QFrame to create a border around another layout or a line between two layouts.

      I know that you can set the design of the QFrame, as shown in the image in the documentation with e.g. qframe.setFrameStyle(QFrame.Box | QFrame.Plain) and the border's thickness with qframe.setLineWidth(3).

      I also know that you can alternatively use QSS to set the border thickness and even the color:

      qframe.setStyleSheet("QFrame#myqframe {border: 1px solid red}")
      

      Now I'm wondering: Is it also possible to set the actual frame style using only QSS? I tried this but it didn't work (didn't display anything):

      qframe.setStyleSheet(
      "QFrame#myqframe {"
          "frameShape: box;"
          "frameShadow: raised"
          "border: 3px solid black"
      "}")
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote last edited by
      #2

      @Neph
      The reference for QT stylesheets is at https://doc.qt.io/qt-6/stylesheet-reference.html. You will find QFrame listed there. When you follow the links you get to see all the attributes Qt supports. So far as I know neither frameShape nor frameShadow are supported, and similarly for most others --- Qt only supports very limited subset of the most common ones.

      N 1 Reply Last reply
      0
      • JonBJ JonB

        @Neph
        The reference for QT stylesheets is at https://doc.qt.io/qt-6/stylesheet-reference.html. You will find QFrame listed there. When you follow the links you get to see all the attributes Qt supports. So far as I know neither frameShape nor frameShadow are supported, and similarly for most others --- Qt only supports very limited subset of the most common ones.

        N Offline
        N Offline
        Neph
        wrote last edited by
        #3

        @JonB Thanks for the link! There's border-radius, which makes the plain "StyledPanel" style possible but the website only mentions a shadow for "PaletteRole". Does this mean that you can't achieve the "raised" or "sunken" styles purely using QSS?

        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