Recently I came to SO in this question asking how could I get my hands on a QComboBox' QScrollBar in order to change its thickness. After reading the replies, I tried Marco A. solution for my Qt Embedded application and it didn't worked. Then, for test, I changed the compilation environment to Desktop and the fix worked!
So essentially my problem is that when I try to change a QComboBox's QScrollBar width in Qt for Embedded Linux (ARM), nothing happens, but if I compile the exact same code for Qt for Desktop, it works. The following is the code I'm using for tests:
QAbstractItemView* poView = ui->comboBox->view();
QScrollBar* poBar = poView->verticalScrollBar();
poBar->setStyleSheet("width: 50px;");
and there is another code that does the same, but shows the same problem:
ui->comboBox->setStyleSheet("QScrollBar:vertical { width: 50px; }");
With comboBox
being declared in the ui form in Qt Designer (inside Qt Creator).
Qt versions are the same for Desktop and Qt for Embedded Linux (4.8.5). Another thing I found strange (but should have nothing to do with it) is that compiling the same code again for Desktop shows a QComboBox with a Windows XP style, while for Embedded the Plastique style is used (I notice that quite clearly due to Plastique showing three instead of two buttons to scroll the scroll bar).
So what could be happening? How may I solve this problem?
I noticed the same symptoms. In Qt a lot of the drawing, I understand, has been delegated to the styles, and the Plastique style seems to have a bug in that it doesn't seem to draw a vertical scroll bar in the right coordinates if it doesn't have the default size. So if you do this:
QScrollBar:vertical
{
min-width: 35px;
width: 35px;
}
you end up with the symptoms you described. But, AFAICS there's something wrong with the handling of margins as well! If you play around with the margins, e.g. like this:
QScrollBar:vertical
{
min-width: 35px;
width: 35px;
margin-right: 35px;
}
you should be able to work around the bug.
Worked for me at least.