QComboBox drop-down stylesheet issue
-
Hi folks,
after have spent hours in googling and trying, I'm still unable to resize drop-down width button of QComboBox with StyleSheet.
The thing looks to be easy, but, actually, not to me.
My code line is this (where myObject is parent of everything in the application):myObject->setStyleSheet("QComboBox::drop-down { width: 34px;}");
but drop-down doesn't change its size, keeping the default one!
QComboBox in my project has nothing special, just a QListView setted as its view to increment items' spacing (it's a touch screen application, that's why I need a bigger drop-down button). Here how it's defined:
ListView->setStyleSheet("QListView::item { margin: 7px;}\n");
ListView->setFocusPolicy(Qt::NoFocus);
this->setView(ListView); // "this" is a QComboBox derived classHope anyone can help me to fix this problem,
Thanks in advance
Andrea -
Hi folks,
after have spent hours in googling and trying, I'm still unable to resize drop-down width button of QComboBox with StyleSheet.
The thing looks to be easy, but, actually, not to me.
My code line is this (where myObject is parent of everything in the application):myObject->setStyleSheet("QComboBox::drop-down { width: 34px;}");
but drop-down doesn't change its size, keeping the default one!
QComboBox in my project has nothing special, just a QListView setted as its view to increment items' spacing (it's a touch screen application, that's why I need a bigger drop-down button). Here how it's defined:
ListView->setStyleSheet("QListView::item { margin: 7px;}\n");
ListView->setFocusPolicy(Qt::NoFocus);
this->setView(ListView); // "this" is a QComboBox derived classHope anyone can help me to fix this problem,
Thanks in advance
Andrea@Andrea Have you tried
qApp->setStyleSheet(....)Btw: I'm not sure what you're trying to accomplish by creating a different object than
qAppas the parent of 'everything', but this sounds like a very bad idea, since such an object already exists, namelyqApp -
@Jakob Thanks for your suggestion, now it works.
About the "parent of everything", I've forgotten of QApplication, which still does its function. My object is simply something that contains every frame, objects and other to be displayed.
Many thanks
Andrea -
@Jakob Thanks for your suggestion, now it works.
About the "parent of everything", I've forgotten of QApplication, which still does its function. My object is simply something that contains every frame, objects and other to be displayed.
Many thanks
Andrea@Andrea You mentioned 'My object is simply .... to be displayed' - if that were really the case, setting the stylesheet on that object should work AFAIK.
If I understand you correctly, you're talking about some
QMainWindow-ish type of object. That would actually make sense, and is not a bad idea, but the standard Qt-way, so neglect my previous remark about that. But still it surprises me that didn't work, as stylesheet are supposed to be 'cascading'. But alas, if it works, it works! -
@Jakob Thanks for your suggestion, now it works.
About the "parent of everything", I've forgotten of QApplication, which still does its function. My object is simply something that contains every frame, objects and other to be displayed.
Many thanks
Andrea