⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

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");
    this->setView(ListView); // "this" is a QComboBox derived class

    Hope anyone can help me to fix this problem,

    Thanks in advance

  • @Andrea Have you tried


    Btw: I'm not sure what you're trying to accomplish by creating a different object than qApp as the parent of 'everything', but this sounds like a very bad idea, since such an object already exists, namely qApp

  • @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 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!

  • @Andrea Oh, btw, if the issue has been resolved, don't forget to mark the question as solved, using the box at the bottom right of the original question.

Log in to reply