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 853 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 14 Jan 2020, 03:11 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.

    J J 2 Replies Last reply 14 Jan 2020, 06:25
    0
    • S spobit
      14 Jan 2020, 03:11

      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.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 14 Jan 2020, 06:25 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 14 Jan 2020, 12:42 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
          14 Jan 2020, 03:11

          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.

          J Offline
          J Offline
          JonB
          wrote on 14 Jan 2020, 12:49 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 15 Jan 2020, 14:13
          0
          • S Offline
            S Offline
            spobit
            wrote on 15 Jan 2020, 14:12 last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • J JonB
              14 Jan 2020, 12:49

              @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 15 Jan 2020, 14:13 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.

              J 1 Reply Last reply 15 Jan 2020, 15:17
              0
              • S spobit
                15 Jan 2020, 14:13

                @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.

                J Offline
                J Offline
                JonB
                wrote on 15 Jan 2020, 15:17 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

                1/7

                14 Jan 2020, 03:11

                • Login

                • Login or register to search.
                1 out of 7
                • First post
                  1/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved