测试代码:
void OsgEarthGraphicsView::resizeEvent(QResizeEvent* event) { //if (scene()) //{ // scene()->setSceneRect(QRect(QPoint(0, 0), event->size())); //} QRect rect = this->rect(); std::cout << "this->rect()" << std::endl; std::cout << rect.x() << ' ' << rect.y() << ' ' << rect.width() << ' ' << rect.height() << ' ' << std::endl; QSize thissize = this->size(); std::cout << "this->size()" << std::endl; std::cout << thissize.width() << ' ' << thissize.height() << std::endl; QSize size = event->size(); std::cout << "event->size()" << std::endl; std::cout << size.width() << ' ' << size.height() << std::endl; }
结果:
event->size()要比前两者要小一点,估计是窗口边框的缘故。