How to change the size of a QComboBox's QScrollBar?

后端 未结 2 1581
孤独总比滥情好
孤独总比滥情好 2020-12-20 01:50

I\'m using a QComboBox with some items to the point that, when the widget that shows all available items in the QComboBox appears, only some of the items are visible with th

相关标签:
2条回答
  • 2020-12-20 02:16

    The scroll bar isn't a member of the QComboBox class, it's a member of the underlying QAbstractItemView. Try something like the following (pseudo-code):

    QListView* abby = new QListView();
    QWidgetList list = abby->scrollBarWidgets(Qt::AlignRight);
    for (auto itr = list.begin(); itr != list.end(); itr++)
    {
        (*itr)->setMinimumWidth(100);
    }
    QComboBox combo;
    combo.setView(abby);
    

    The scrollbarwidgets returns a widget list of the scroll bars for that alignment. You can then set the properties on the scroll bar pointers.

    0 讨论(0)
  • 2020-12-20 02:38
    1. Get the combobox's QAbstractItemView via view()

    2. That class inherits from QAbstractScrollArea, thus inherits the verticalScrollBar method

    e.g.

    QAbstractItemView *qv = combobox.view();
    QScrollBar *scrollbar = qv->verticalScrollBar();
    // Adjust size via setStyleSheet or hint/width
    
    0 讨论(0)
提交回复
热议问题