Results 1 to 4 of 4

Thread: Display image fullscreen, the best way?

  1. #1
    Join Date
    Jul 2008
    Posts
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Display image fullscreen, the best way?

    Allright, I'll try it over here, because I get no response on the mailing list..

    Anyway, I want to display some images from a sqlite database. Currently I'm doing the following, which works, but not as I want to:
    Qt Code:
    1. scene->addPixmap(QPixmap("/home/user/image/jpg"));
    2. view->setBackgroundBrush(QBrush(Qt::black));
    3. view->setScene(scene);
    4. view->updateGeometry();
    5. view->show();
    6. view->showFullScreen();
    To copy to clipboard, switch view to plain text mode 

    About this, I have a couple of questions:
    - Is this the right way to do? I have seen a lot of functions about displaying images, but I'm not sure which one to use.
    - How do I scale the image, so that, when the image is too large for the screen, it will be resized?
    - Currently, I get borders around the window. I tried setting flags with view->setWindowFlags(Qt::FramelessWindowHint), but that only removes the titlebar when I remove the view->showFullScreen().

    I'm using Qt 4.4.0, by the way.

    Thanks in advance!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Display image fullscreen, the best way?

    You don't need QGraphicsView to display a single image, especially if you want to resize it. Simple QLabel will do.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Display image fullscreen, the best way?

    And you can use QWidget::showFullScreen() to display it full screen.

  4. #4
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Display image fullscreen, the best way?

    Currently, I get borders around the window. I tried setting flags with view->setWindowFlags(Qt::FramelessWindowHint), but that only removes the titlebar when I remove the view->showFullScreen().
    so does the showFullScreen() behaves the same if you use QLabel instead of view.. ?

    How do I scale the image, so that, when the image is too large for the screen, it will be resized?
    Try adjustSize if you prefer QWidget or use Qt layout scheme,the second is preferable..

Similar Threads

  1. Replies: 32
    Last Post: 30th March 2008, 20:00
  2. Display only PNG image on desktop
    By durbrak in forum Qt Programming
    Replies: 32
    Last Post: 15th March 2008, 21:55
  3. Display and divide the image
    By kiransu123 in forum Qt Programming
    Replies: 19
    Last Post: 5th March 2007, 20:40
  4. Simple display of an image
    By bruccutler in forum Newbie
    Replies: 1
    Last Post: 15th January 2007, 23:49
  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.