使用以下代码,在我的工作站(QtCreator 一个“手动”运行)上一切正常。但是在另一台没有安装 Qt 的电脑上,我的应用程序没有显示 QGraphicsPixmapItem。
图像 = 新 QGraphicsPixmapItem(QPixmap(urlFile)); 图像->setZValue(-5000.0); 场景->setSceneRect(QRectF(0, 0, image->pixmap().width() + 200, image->pixmap().height() + 200)); 场景->添加项目(图像); view->setMaximumWidth(image->pixmap().width() + 200); 视图->setMaximumHeight(图像->pixmap().height() + 200); qreal centerX = (scene->width() / 2.0) - (image->pixmap().width() /2.0); qreal centerY = (scene->height() / 2.0) - (image->pixmap().height() /2.0);; 图像->setOffset(QPointF(centerX, centerY));
你知道为什么吗 ?