PDA

View Full Version : Display image fullscreen, the best way?



Hmail01
17th July 2008, 23:11
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:

QGraphicsScene *scene = new QGraphicsScene();
scene->addPixmap(QPixmap("/home/user/image/jpg"));
QGraphicsView *view = new QGraphicsView();
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!

jacek
26th July 2008, 01:43
You don't need QGraphicsView to display a single image, especially if you want to resize it. Simple QLabel will do.

wysota
26th July 2008, 22:14
And you can use QWidget::showFullScreen() to display it full screen.

salmanmanekia
27th July 2008, 00:00
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..:)