displaying image using label in Qt4.7
Hello,
I am a beginner in developing with Qt and I am trying to create my first application. I want to create a window with a button and a label, in order to use a pixmap and finally display an image on the label. When I run my project I do not get any errors, but I do not see my image in my form either. I hope someone could help me and give me a solution. I have created the following code.
Thanks in advance
/////////// open_image.h /////////////
- #ifndef OPEN_IMAGE_H
- #define OPEN_IMAGE_H
- #include <QtGui/QMainWindow>
- #include "ui_open_image.h"
- {
- Q_OBJECT
- public:
- ~open_image();
- private:
- Ui::open_imageClass ui;
- private slots:
- void doThingA(void);
- };
- #endif // OPEN_IMAGE_H
////////////// open_image.cpp ////
- #include "open_image.h"
- {
- setupUi(this);
- }
- open_image::~open_image()
- {
- }
- void open_image::doThingA(void)
- {
- }
/////////// main.cpp //////
- #include "open_image.h"
- #include <QtGui/QApplication>
- int main(int argc, char *argv[])
- {
- open_image w;
- w.show();
- return a.exec();
- }
Mark up code, Tobias
5 replies
What do you mean? I also tested the followings but with no results again. Do you thing it is a too long directory? Or there is a syntax error?
label->setPixmap(QPixmap(”:/Users/manolis/Desktop/data/test.png”, 0, Qt::AutoColor)); label->setPixmap(QPixmap(”:/open_image/C:/Users/manolis/Desktop/data/test.png”)); label->setPixmap(QPixmap(“C:/open_image/C:/Users/manolis/Desktop/data/test.png”, 0, Qt::AutoColor));It is in the resources (.qrc file), with URL, :/open_image/C:/Users/manolis/Desktop/data/test.png. I have typed this
- label->setPixmap(QPixmap(”:/open_image/C:/Users/manolis/Desktop/data/test.png”, 0, Qt::AutoColor));
- label->setPixmap(QPixmap(“C:/Users/manolis/Desktop/data/test.png”, 0, Qt::AutoColor));
- label->setPixmap(QPixmap(”:/C:/Users/manolis/Desktop/data/test.png”, 0, Qt::AutoColor));
- label->setPixmap(QPixmap(”:/Users/manolis/Desktop/data/test.png”, 0, Qt::AutoColor));
but I did not get anything
You must log in to post a reply. Not a member yet? Register here!



