Unsolved Styling QListWidget
-
Hi, I am having issue styling my ListWidget. My ListWidget is created in the UI file in qt creator. Also, I have make use of the stylesheet to customize the appearance of the ListWidget that i have.
QListView::item
{
height: 25px;
}QListView::item::selected
{
background-color: rgb(255,128,0);
min-height: 25px;
border-radius: 0px;
}On and off, Items will be added to the ListWidget while the program run. However, i notice the margin between items added in the UI and using code is different. How can i correct it?
Secondly, How can I draw a line to separate the items in a ListWidget?
Lastly, how do i make the ListWidget scroll able?
Please advise, Thank you
-
Hi,
Please provide a minimal compilable example that shows the behaviour.
-
QListView::item::selected
There should be only one colon before the state-specifier "selected".
Like this:QListView::item:selected
To draw a separator between items, you could do something like this:
QListView::item:!last { border-bottom: 1px solid black; }
This should draw a 1px black border on every item's bottom except for the last item.
The QListView will display scrollbars when the content becomes larger than the available space. If that's not the case, then you're probably handling its size logic manually somewhere or you have a bug in your layout. ;)
-
Hi! I have tried using "QListView::item:selected" and it works!! As for the separator, how to i draw it for specific items in the QListWidget? For instance, I have 5 items in my ListWidget (A, B, C, D, E). The position of this 5 items will change now and then. So how to ensure that always after item C i will draw the separator?