如何更改QComboBox的QScrollBar的大小? [英] How to change the size of a QComboBox's QScrollBar?

查看:433
本文介绍了如何更改QComboBox的QScrollBar的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有某些项目的QComboBox,以至于当显示可显示QComboBox中所有可用项目的小部件出现时,只有某些项目可以通过QScrollBar看到,其他项目可以通过QScrollBar看到。

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 the other accesible through a QScrollBar.

问题是QScrollBar变薄,我想使其变大。我在网上做了一些研究,发现了一些改变QScrollBar宽度的方法(请参阅下面的参考资料),但问题是我根本找不到用于访问QComboBox的QScrollBar的方法。

The problem is that the QScrollBar is to thin and I want to make it larger. I did some research on the web and I did found some ways to change the QScrollBar's width (see references below), but the problem is that I simply can't find the method to access the QComboBox's QScrollBar.

那么,鉴于这个问题,我该怎么做? (我想您可能会以一种不需要我访问QScrollBar的方式呈现给我,或者显示我如何访问它。)。

So, given this problem, how can I do this change? (I guess you may either present me with a way that don't require me to access the QScrollBar or show how may I access it).

参考文献:

  • vertical scrollbar width - Direct access and style
  • How to get scroll bar real width in Qt? - Again by pixlMetric (only access)
  • How to increase QTableWidget Vertical Scrollbar width? - Using stylesheet (a preferable method if there is a way to make it apply to all QScrollBars available in the project)
  • Other options are discussed here

推荐答案


  1. 通过QAbstractItemView /doc/qt-4.8/qcombobox.html#view rel = nofollow> view()

  1. Get the combobox's QAbstractItemView via view()

该类继承自 QAbstractScrollArea ,因此继承了 verticalScrollBar方法

That class inherits from QAbstractScrollArea, thus inherits the verticalScrollBar method

例如

QAbstractItemView *qv = combobox.view();
QScrollBar *scrollbar = qv->verticalScrollBar();
// Adjust size via setStyleSheet or hint/width

这篇关于如何更改QComboBox的QScrollBar的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆