QPIXMAP图像未显示
QPixmap Image doesnt appear
im新的QT和IM在其中制作游戏。我想显示图标,但是在将一些代码放置后,我找不到任何地方。我很困惑,因为我没有任何错误,所以我很确定我没有添加一些东西。帮助。
战斗。H文件
#ifndef COMBAT
#define COMBAT
#include <QImage>
#include <QGraphicsPixmapItem>
class Combat: public QGraphicsPixmapItem{
public:
// constructors
//Combat(QPixmap *parent=NULL);
Combat(const QString x);
// setters/getters
void getOwner(QString x);
private:
QString owner;
};
战斗.cpp
#include "Combat.h"
#include <QGraphicsScene>
Combat::Combat(const QString x){
// draw graphics
setPixmap(QPixmap(x));
}
void Combat::getOwner(QString x){
owner = x;
}
#endif // COMBAT
interface.h
#ifndef INTERFACE
#define INTERFACE
#include <QList>
#include "Hex.h"
#include "Combat.h"
class Interface{
public:
// constructors
Interface();
// getters/setters
QList<Hex*> getHexes();
void getOwner(int x);
// public methods
void placeHexes();
void placeCombat();
private:
void createHexColumn(int x, int y, int numOfRows);
QList<Hex*> hexes;
void createCombatIcon(int x, int y, QString z);
int owner;
};
#endif // INTERFACE
interface.cpp
#include "Interface.h"
#include "Game.h"
extern Game* game;
Interface::Interface(){
}
QList<Hex *> Interface::getHexes(){
return hexes;
}
void Interface::placeHexes(){
createHexColumn(100,100,6);
}
void Interface::placeCombat()
{
createCombatIcon(100,100,":/grafika/atak_magiczny.png");
}
void Interface::createCombatIcon(int x, int y, QString z)
{
Combat* icon = new Combat(z);
icon->getOwner("player1");
icon->setPos(x,y);
game->scene->addItem(icon);
}
我不确定在哪里缺少的东西
我通过在qt creator中添加我的图形来解决问题...
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- C++射线示踪剂ppm表示没有足够的数据来显示图像
- 我在 OpenGL 中显示图像时遇到问题
- 无法在 Opencv 中显示图像导致内存位置
- 从C++调用网络摄像头并在 Python 中显示图像
- C++列出屏幕以在第二台显示器中显示图像
- 如何用QT显示图像
- 如何在 QGraphicsView 中显示图像
- C++/openCV - 为什么显示图像会产生 Linux 分割错误?(打开CV错误?
- 在C 中显示图像及其元数据
- C++显示图像并将其保持到下一张图像的最佳方法
- 如何使用SDL_surface在用户定义的矩形上显示图像?
- 如何使用QVector的QPixmap显示图像?
- 如何在任何使用 Opencv 的计算机上显示图像
- 使用 qt 和 opengl、定时精度和垂直同步问题、c++ 显示图像
- QLabel像视频一样显示图像
- 使用 c++ 显示图像
- Qt表查看单元格中的显示图像并在单击时获取路径
- 在Visual C 控制台应用程序中显示图像
- 如何使用Createbsection显示图像