join Qlabel in a Qdialog

1

I have a question about how to connect a QLabel in a QDialog .

The idea is to be able to open a QDialog before running the program.

I leave part of the code:

QDialog jjj;
QLabel *logojjj;
    logojjj->setPixmap(QPixmap::fromImage(QImage(":/icons/jjj_2015_2.jpg")).scaled(QSize(120,120),Qt::KeepAspectRatio));
jjj.show();
Gui::MainWindow win;
sleep(3);
jjj.close();
win.show();
return app.exec();

That QLabel I want to leave it inside the QDialog (all this is inside the main).

    
asked by Adolfo Comas 25.07.2017 в 20:52
source

1 answer

1
QLabel *logojjj;
logojjj->setPixmap(QPixmap::fromImage(// ...

At what point are you creating the QLabel ? In the code that you are showing you are declaring a pointer and then using a supposed object pointed to by it ... but you have not initialized the pointer anywhere. If you have not skipped lines in the example this will cause a fall of the program.

QLabel *logojjj = new QLabel(&jjj);
logojjj->setPixmap(QPixmap::fromImage( // ...

With this the label should already appear within jjj .

By the way, consider the possibility of leaving the dialogue designed with the form editor and thus avoid dealing with the code that designs the windows ... which can be extremely chaotic.

    
answered by 26.07.2017 / 09:15
source