简体   繁体   中英

Qt QGraphicsView or QLabel

For a school project we need to make the game Puerto Rico in Qt. I was looking at QGraphicsView to display the gameboard, but it seems that this was a lot harder than i tought and had a lot of functions i don't need. So now my question is it also possible to achieve something like a gameboard using only label and display pictures in them?

You can display a picture using a QLabel widget using the pixmap property . You can check the detailed information about QPixmap class and use links from it to learn which image class (QPixmap, QImage, QBitmap or QPicture) best fits your needs

You can always just subclass QWidget and override the paintEvent(QPaintEvent *) method to draw the board using a QPainter. (You'd probably also want to override the mousePressEvent(QMouseEvent *) and mouseReleaseEvent(QMouseEvent *) methods to react to the player's mouse inputs as well; and be sure to call update() whenever you want to schedule another call to paintEvent(QPaintEvent *) to redraw the game board)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM