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 access data of style sheet
Forum Updated to NodeBB v4.3 + New Features

How to access data of style sheet

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 859 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.
  • S Offline
    S Offline
    spobit
    wrote on last edited by
    #1

    I set some sytle sheet to a table, such as:

    QTableView {
    	gridline: #f00;
    	outline: none;
    }
    
    QTableView::item {	
    	border: 1px solid #0f0;
    	border-top: none;
    	border-left: none;
    	padding: 0px 10px;
    }
    
    QTableView::item:hover {
    	background: #100000ff;
    }
    
    QTableView::item:selected {
    	background: #aa0000ff;
    	color: #000;
    }
    

    but, how to access the borders, margins, and padding? or rebuild qt to do this? or export some class?

    Thanks.

    jsulmJ JonBJ 2 Replies Last reply
    0
    • S spobit

      I set some sytle sheet to a table, such as:

      QTableView {
      	gridline: #f00;
      	outline: none;
      }
      
      QTableView::item {	
      	border: 1px solid #0f0;
      	border-top: none;
      	border-left: none;
      	padding: 0px 10px;
      }
      
      QTableView::item:hover {
      	background: #100000ff;
      }
      
      QTableView::item:selected {
      	background: #aa0000ff;
      	color: #000;
      }
      

      but, how to access the borders, margins, and padding? or rebuild qt to do this? or export some class?

      Thanks.

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @spobit You can use https://doc.qt.io/qt-5/qwidget.html#styleSheet-prop to get the style-sheet and then parse it to get what you need.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        spobit
        wrote on last edited by
        #3

        Thanks for answer.

        It is a method, but I think is not best. Style Sheet has inheritance capacity, and it is complex.

        1 Reply Last reply
        0
        • S spobit

          I set some sytle sheet to a table, such as:

          QTableView {
          	gridline: #f00;
          	outline: none;
          }
          
          QTableView::item {	
          	border: 1px solid #0f0;
          	border-top: none;
          	border-left: none;
          	padding: 0px 10px;
          }
          
          QTableView::item:hover {
          	background: #100000ff;
          }
          
          QTableView::item:selected {
          	background: #aa0000ff;
          	color: #000;
          }
          

          but, how to access the borders, margins, and padding? or rebuild qt to do this? or export some class?

          Thanks.

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @spobit said in How to access data of style sheet:

          but, how to access the borders, margins, and padding?

          What do you mean by "access"? The sheet already sets e.g. borders. Do you mean be able from code to translate the end result settings into, say, QStyle stuff and read borders from there? I don't think that's how it works, stylesheet end results cannot be "read back" from Qt.

          S 1 Reply Last reply
          0
          • S Offline
            S Offline
            spobit
            wrote on last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • JonBJ JonB

              @spobit said in How to access data of style sheet:

              but, how to access the borders, margins, and padding?

              What do you mean by "access"? The sheet already sets e.g. borders. Do you mean be able from code to translate the end result settings into, say, QStyle stuff and read borders from there? I don't think that's how it works, stylesheet end results cannot be "read back" from Qt.

              S Offline
              S Offline
              spobit
              wrote on last edited by spobit
              #6

              @JonB
              I want to access it when I do `QItemDelegate::paint()'; and I want to draw border before draw background, maybe background color has alpha. I want to draw border then background when row selecting, and so so on.

              JonBJ 1 Reply Last reply
              0
              • S spobit

                @JonB
                I want to access it when I do `QItemDelegate::paint()'; and I want to draw border before draw background, maybe background color has alpha. I want to draw border then background when row selecting, and so so on.

                JonBJ Online
                JonBJ Online
                JonB
                wrote on last edited by JonB
                #7

                @spobit
                As I said, to the best of my knowledge you cannot do this: you won't get to access/be told about the final disposition of all the stylesheet attributes in code. I stand to be corrected --- please let us (me) know if that is not the case and you can access the final results of the style rules in the way you want!

                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