Show a BMP image
-
Hi all,
I'm making a program to display a bmp image after a video ends ..
I wrote this code:
@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <Phonon/VideoPlayer>
#include <Phonon/MediaObject>
#include <Phonon/MediaSource>
#include <QString>
#include <QImageReader>
#include <QImage>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsPixmapItem>
#include <QLabel>MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);Phonon::MediaObject *media = new Phonon::MediaObject(this); media->setCurrentSource(Phonon::MediaSource(QString("/home/user/Desktop/video.avi"))); ui->videoPlayer->play(media->currentSource());
}
MainWindow::~MainWindow()
{
delete ui;
}void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}void MainWindow::on_videoPlayer_finished()
{
ui->videoPlayer->close();
QGraphicsScene scene;
QGraphicsView view(&scene);
QGraphicsPixmapItem item(QPixmap("/home/user/Desktop/mappa.bmp"));
scene.addItem(&item);
view.show();}
@
At finished i not view BMP image..
You can help me, please?
thanks at all -
You didn't position(and/or layout) your QGraphicsView in your central widget.
But, it seems to me even if you do that, the design would look bad in this case.Though I did't have any experience with phonon videoplayer widget class, it should be able to show any simple image file to its display or at least you can derive your own videoplayer class from it, and override QWidget::paintEvent() to show your image whenever you want.
-
i've resolved thanks