2011-12-20 39 views
0

在QtCreator中,我使用了一個表單來繪製網格佈局。在我的主窗口類中,我向該網格佈局添加了一個QGraphicsScene包裝對象,並使用包裝類通過鼠標單擊將點繪製到場景上。是否可以通過GridLayout獲取大小?

發生了什麼事是我點擊相對QGraphicsScene包裝,這不是我要的效果是負面的位置,所以我想確保我知道我的QGraphicsScene和網格填充的座標佈局。

如何獲得由網格佈局填充的大小?目前,我正在做一些這樣的效果......

view = new QGraphicsViewWrapper(); 
ui->gridLayout->addWidget(view); 

QGraphicsViewWrapper::QGraphicsViewWrapper(QWidget *parent) : QGraphicsView(parent) 
{ 
    scene = new QGraphicsScene(50, 50, 350, 350); 
    this->setSceneRect(50, 50, 350, 350); 
    this->setScene(scene); 
    this->setGeometry(QRect(20, 50, 400, 400)); 
} 

回答

0

不知道我完全理解你的目標,但你能不能做:

QRect size = ui->gridLayout->geometry(); 
相關問題