简体   繁体   中英

how to display a jpeg image completely on main window in Qt

I have a gui application which accepts some commands from other application.

There is a scenario where gui will receive a command to display some jpeg image completely on the main window, overshadowing all of gui on the window and then again I need to clear that image with another command.

For this I will need to call a member function and need to do all this stuff there, but I don't know how can I display the image on main window from there.

can anybody please help me with that.

I have tried the below code.

void App::display_testpattern(QString path){

QPixmap imageObject(path);
imageObject = imageObject.scaled(300,300,Qt::IgnoreAspectRatio);
mylabel=new QLabel("",backup);
mylabel->setGeometry(QRect(0,0,300,300));
mylabel->setPixmap(imageObject);

}

and this works for me only when I call it from constructor. But I need to call it from some other slot and it does not work for me. any suggestions on this

Yes we can do the way I mentioned at the end of my question. The problem was allocation of QLabel. we need to allocate QLabel in constructor and this will work fine.

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM