Results 1 to 10 of 10

Thread: Qt Image Display...

  1. #1
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    1
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Qt Image Display...

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Image Display...

    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.

  3. #3
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    1
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Qt Image Display...

    thank you flyer...

    mahe2310

    Quote Originally Posted by high_flyer
    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Image Display...

    Then the QPainter::show() paintes...
    I meant QFrame::show() ofcourse...

  5. #5
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    1
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Qt Image Display...

    I got the the results by reordering the commands as you suggested...

    How to initialise a QKeyEvent?

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Image Display...

    How to initialise a QKeyEvent?
    What do you mean?
    Could you explain a bit what you want to do?

  7. #7
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    1
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Qt Image Display...

    Quote Originally Posted by high_flyer
    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

  8. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Image Display...

    I see you opened another thread for that question, I'll answer you there.

  9. #9
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    1
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Qt Image Display...

    Quote Originally Posted by high_flyer
    I see you opened another thread 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

  10. #10
    Join Date
    Jul 2013
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Image Display...

    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
    Attached Files Attached Files

Similar Threads

  1. Replies: 2
    Last Post: 29th September 2008, 00:08
  2. Replies: 7
    Last Post: 13th August 2008, 18:27
  3. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 15:36
  4. Display only PNG image on desktop
    By durbrak in forum Qt Programming
    Replies: 32
    Last Post: 15th March 2008, 21:55
  5. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.