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:
Code:
scene
->addPixmap
(QPixmap("/home/user/image/jpg"));
view
->setBackgroundBrush
(QBrush(Qt
::black));
view->setScene(scene);
view->updateGeometry();
view->show();
view->showFullScreen();
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!
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.
Re: Display image fullscreen, the best way?
And you can use QWidget::showFullScreen() to display it full screen.
Re: Display image fullscreen, the best way?
Quote:
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.. ?
Quote:
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..:)