Reputation: 37
I'm trying to add an image to a QLabel on a Qt creator program. However when compiling the program I get an error: C:\Users\*****\Documents\GameAPP\main.cpp:12: error: C2027: use of undefined type 'QBitmap'
Using Qt version 5.7 and 5.6 on Windows 10.
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
QLabel *l = new QLabel();
QPixmap p("C:\Users\*****\Pictures\Start_Orb.png");
l->setPixmap(p);
l->setMask(p.mask()); //error at this line
l->setFixedSize(20, 20);
l->move(20, 20);
l->show();
return a.exec();
}
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPixmap>
#include <QLabel>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
Upvotes: 1
Views: 3478