Solved Jpeg Image not getting displayed
-
Hi
Using sleep is a bad idea.
It will halt the event loop and might prevent the window from
showing/painting. Not sure its that but easy to test.void Base::displaySysInfoScreen()
{
QPixmap pm("usr/.images/is5RaptorSysInfo.jpeg");
presnLabel.setPixmap(pm);
presnLabel.show();
// sleep(5) ;
// presnLabel.hide();
}and then call void Base::displaySysInfoScreen() directly.
Does image show ?
-
Hi,
Your
sleep
call blocks the event loop thus your label never gets shown. Use a single shot QTimer if you want to hide your widget after a given delay. -
I have removed the sleep but still not able to see image, below is the changed code.
Also changed the slot function to "rcvPresntationFinisedNotif" which is calling displaySysInfoScreen().void Base::displaySysInfoScreen() { //Display the Raptor system information screen QPixmap pm("usr/.images/is5RaptorSysInfo.jpeg"); presnLabel.setPixmap(pm); presnLabel.show(); //sleep(5) ; //presnLabel.hide(); } /SLOT fn */ void Base::rcvPresntationFinisedNotif() { qDebug()<< "Main Thread (BASE): Received raptor boot presentation finished signal from base thread\n"; displaySysInfoScreen(); //displayLsrScreen(); qDebug()<< "Main Thread (BASE): Now starting worker threads , connecting to notif server and watchdog msg queue\n"; drpThread->start(); clientThread->start(); //Connect to the server clientThread->serverConnect(); //Connect to the message queue in watchdog clientThread->watchdogConnect(); }
-
You are using a relative path so unless the folder is located in the same folder as the application, the file won't be found.
-
@nitks.abhinav said in Jpeg Image not getting displayed:
QPixmap pm("usr/.images/is5RaptorSysInfo.jpeg");
Looks like you forgot / before usr.
Also: this path is quite unusual, I never saw anybody creating a hidden directory in /usr, why are you doing this? It is against UNIX/Linux file system structure. If you want to put some data globally for your application do it in /usr/share/YOUR_APP_NAME -
Couple of issues were there , path with missing / and also jpeg plugin was not there, Thank you.
I have couple of more questions related to this:
- Can bmp image be displayed in similar way?
- Image is not aligned to the LCD screen, I can see it shifted to both right and up. How to align it?
Thanks
-
hi
1:yes
http://doc.qt.io/qt-5/qtimageformats-index.html
2: not sure what u see but the label can center it
there is a property -
I have used presnLabel.showMaximized(); and it seems to be working fine. Assume it is correct way.
-
yes when you use the label as window it should be fine.
-
Thankyou for all the help!
-
@nitks.abhinav
Np, happy programming and remember to set as solved