如何在Qt中获取滚动条的实际宽度? [英] How to get scroll bar real width in Qt?

查看:919
本文介绍了如何在Qt中获取滚动条的实际宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个自定义小部件,该小部件基本上是一堆textedit,右侧有一个垂直滚动条.为了确定小部件的大小,我必须找到滚动条的宽度,因为texedits的几何形状取决于它.只需调用scroll_bar-> width();对于新创建的垂直条返回101,这显然是错误的.

I'm trying to make a custom widget, which is basically a bunch of textedits with a single vertical scroll bar on the right. To keep widget size determined, I have to find a width of the scrollbar, as texedits geometry depends on it. Simply calling scroll_bar->width(); for freshly created vertical bar returns 101, which is obviuosly wrong.

那么,有没有办法在Qt 3.2.3中正确确定垂直滚动条的宽度?

So, is there a way to determine vertical scroll bar width correctly in Qt 3.2.3?

推荐答案

int w = qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent);

这篇关于如何在Qt中获取滚动条的实际宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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