How to access data of style sheet
-
wrote on 14 Jan 2020, 03:11 last edited by
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.
-
wrote on 14 Jan 2020, 12:42 last edited by
Thanks for answer.
It is a method, but I think is not best. Style Sheet has inheritance capacity, and it is complex.
-
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.
wrote on 14 Jan 2020, 12:49 last edited by@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. -
wrote on 15 Jan 2020, 14:12 last edited byThis post is deleted!
-
@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.wrote on 15 Jan 2020, 15:17 last edited by JonB@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/7