3
我想用Qt製作遊戲,但是我無法加載圖像。用QImage和QRect顯示圖像
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
image.load("F:/My Workspace/sprite.png");
rect = image.rect();
rect.moveTo(5,5);
}
這是窗口的構造函數。圖像不顯示。我知道如何使用QLabel顯示圖像,但我想使用QRect功能,以便可以移動圖像。
你不能。你的矩形只是...一個矩形!它無法顯示圖像。 – Lol4t0
然後他們是如何在槳上使用長方形的? http://zetcode.com/tutorials/qt4tutorial/breakoutgame/ – Kanghu
他們稍後使用'rect'作爲提示繪製圖像 – Lol4t0