我有以下课程
class QBoardImages
{
public:
QImage empty_white;
QImage empty_black;
QImage possible_move;
QImage lighter;
QImage choosed;
QImage multiple_move;
QImage blue_pawn;
QImage blue_queen;
QImage blue_skydiver;
QImage red_pawn;
QImage red_queen;
QImage red_skydiver;
QBoardImages();
};
使用构造函数,我有:
QBoardImages::QBoardImages()
{
QDir::setCurrent(QApplication::applicationDirPath());
empty_white.load("images/board/white.png");
empty_black.load("images/board/black.png");
lighter.load("images/board/lighter.png");
choosed.load("images/board/choosed.png");
blue_pawn.load("images/board/blue_pawn.png");
blue_skydiver.load("images/board/blue_skydiver.png");
blue_queen.load("images/board/blue_queen");
red_pawn.load("images/board/red_pawn.png");
red_skydiver.load("images/board/red_skydiver.png");
red_queen.load("images/board/red_queen.png");
possible_move.load("images/board/possible_move.png");
}
当然我只想加载这些图像一次,但我无法做到这一点.. 只加载这些图像一次的最佳方法是什么?
谢谢你们