1

enter image description here

Does anyone know how to remove this white space? This is my current stylesheet:

QTableView {
    background-color: #EEEEEE;
}
QTableView::item {
    background-color: transparent;
}
QHeaderView::section {
    background-color: transparent;
    padding: 5px;
    border: 1px solid #D3D3D3;
    border-right: none;
}
QHeaderView::section:selected {
    background-color: #D3D3D3;
}
5
  • 1
    You could try with QHeaderView { background: transparent } and QTableCornerButton::section { background: transparent }, as explained in the Qt Style Sheets Reference. But you must also be aware that the style may still override that, which is one of the many reasons for which QSS shouldn't be considered reliable in complex cases like this. Commented Nov 17 at 6:47
  • Thank your for answering. QTableCornerButton::section { background: transparent } did indeed fixed the upper left corner, but sadly not the upper right. In this case, what is a reliable method I should use instead of QSS? I appreciate any answer, I'll do the rest of research on my own. Commented Nov 17 at 7:47
  • 1
    There's no absolute answer, and there are no canonical answers that can provide a result that will always be consistent. Qt item views are very complex widgets (involving 5 levels of subclassing, and embedded widgets also based on subclasses) that heavily rely on the underlying QStyle: while some adaptations may be done through QSS or QProxyStyle (not both!), there is always some level of possible inconsistency that will appear on different platforms and setups. If you want absolute and reliable control over appearance, then you have to draw everything on your own. Commented Nov 18 at 4:32
  • 1
    I know that the above can be quite annoying, but you have to understand that: 1. QSS were never intended to be a complete replacement of the default painting (which always relies on the underlying style of each widget); 2. QSS are mostly intended to be a relatively small "adjustment" over the default behavior defined by the defined style; 3. child widgets of complex ones are often treated differently depending on their type, especially when using QSS; 4. QProxyStyles are almost completely ignored when their target widgets involve QSS, even if they're not affected by them. Commented Nov 18 at 4:37
  • 1
    That's how QSS and QStyle works, it may not be optimal, but we can only accept that, and little will be eventually fixed in future Qt versions, except for small adjustments related to raised bugs or new features introduced in the QtWidgets module. The whole QStyle and QSS (which is based on QStyle classes and functions) implementation was implemented decades ago, and is only partially conceptually adherent to modern CSS implementations. This is one of the reasons for which QML was introduced and also why many modern desktop programs rely on "web views" using browser engines for their UIs. Commented Nov 18 at 4:44

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.