本文介绍了获取QGraphicsView的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道某个 QGraphicsView 的大小。它的大小不是固定的,因为窗口小部件是网格布局的一部分。我尝试使用 this-> ui-> myGraphicsView-> width()及其高度等效,但这些值不准确。

I want to know the size of a certain QGraphicsView. Its size isn't fixed because the widget is part of a grid layout. I tried using this->ui->myGraphicsView->width() and its height equivalent but these values aren't accurate.

如何获得 QGraphicsView 的当前大小?

推荐答案

不断接收100x30作为我的QGraphicsView的大小,以及。原来我要求的大小QGraphicsView之前它被显示。

Constantly received 100x30 as the size of my QGraphicsView as well. It turned out I was asking for the size of the QGraphicsView before it was shown.

将我的初始化代码移动到showEvent后,我得到正确的尺寸。

After moving my initialization code to showEvent, I got the correct dimensions.

这篇关于获取QGraphicsView的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-25 16:32