PDA

View Full Version : Qt Image Display...



mahe2310
14th February 2006, 08:29
Hi all...

Can anybody help me knowing why i am not able see any image on the window for the following code

#include<qapplication.h>
#include<qframe.h>
#include<qimage.h>
#include<qpainter.h>
main(int argc, char *argv[])
{
QApplication app(argc,argv);
QFrame frame;
QPainter painter(&frame);
QImage image("test.png");
painter.drawImage(0,0,image);
frame.show();
return app.exec();
}

Regards,

Mahe2310

high_flyer
14th February 2006, 09:34
You don't see the image because it is being painted before the show().
Then the QPainter::show() paintes the frame and deletes the image.
So, you should put the drawImage() call after show().
But even that wont help much, since when you move the widget and a repaint will occur, the image will be gone again.
You need to insert the image drawing to the paintEvent of the QFrame.

mahe2310
14th February 2006, 10:06
thank you flyer...

mahe2310


You don't see the image because it is being painted before the show().
Then the QPainter::show() paintes the frame and deletes the image.
So, you should put the drawImage() call after show().
But even that wont help much, since when you move the widget and a repaint will occur, the image will be gone again.
You need to insert the image drawing to the paintEvent of the QFrame.

high_flyer
14th February 2006, 10:16
Then the QPainter::show() paintes...
I meant QFrame::show() ofcourse...:rolleyes:

mahe2310
15th February 2006, 10:17
I got the the results by reordering the commands as you suggested...

How to initialise a QKeyEvent?

high_flyer
15th February 2006, 20:35
How to initialise a QKeyEvent?
What do you mean?
Could you explain a bit what you want to do?

mahe2310
16th February 2006, 06:40
What do you mean?
Could you explain a bit what you want to do?


I want to know how i have to get a QKeyEvent ...
Thank you for your reply...

Now i understood how to get a keyEvent...
Now can you help me know

1. WhyI am getting all the keyEvents except Arrow Key?
2. Whether the arrow key press is not a part of QKeyEvent Class?

Thank you in advance....

mahe2310

high_flyer
16th February 2006, 09:26
I see you opened another thread (http://www.qtcentre.org/forum/showthread.php?t=693) for that question, I'll answer you there.

mahe2310
16th February 2006, 10:04
I see you opened another thread (http://www.qtcentre.org/forum/showthread.php?t=693) for that question, I'll answer you there.


Hi flyer...

I just cleared the error in arrow key press error...
Now facing problem with Enter key press...

As you suggested i will start a new thread...

Thank you...

mahe2310

chandana
22nd July 2013, 10:06
can any body help me how to pass data from one form to another


i have created one registration forms which includes line edit ,text edit,combobox etc. after filling details in from1 i want the same details to display in form2 after clicking submit button. i have browsed in net but unable to do so .. plz help me:-)
thanku