How to access data of style sheet
-
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.
-
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.
@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.
-
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.
@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. -
@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. -
@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.@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!