Hi,
I have a set of raw image files. Referring to the tutorials, I have written a QImage plugin to read the raw files. and display.
I'm successfully able to display these sequnce of files continuosly. Code is as below.
I would like to know if the approach I have taken is the right one... Is this the practice usually followed.
Ui::MainWindow *ui;
Canvas *scene;
scene = new Canvas(0,0,798,598);
scene->addItem(pixmapItem);
ui->liveFeedView->setScene(scene);
ui->setupUi(this);
QObject::connect(updateTimer,
SIGNAL(timeout
()),
this,
SLOT(doUpdate
()));
updateTimer->start(50);
Ui::MainWindow *ui;
QImage rawImg;
QPixmap *pixmap;
QGraphicsPixmapItem *pixmapItem;
Canvas *scene;
pixmap = new QPixmap(555, 313);
pixmapItem = new QGraphicsPixmapItem();
scene = new Canvas(0,0,798,598);
scene->addItem(pixmapItem);
ui->liveFeedView = new QGraphicsView();
ui->liveFeedView->setScene(scene);
ui->setupUi(this);
QTimer* updateTimer = new QTimer(this);
QObject::connect(updateTimer,SIGNAL(timeout()),this,SLOT(doUpdate()));
updateTimer->start(50);
To copy to clipboard, switch view to plain text mode
"Canvas" is derived from QGraphicsScene. Finally the slot doUpdate is as below:
if(rawImg.loadFromData(imgData[i]))
{
painter.begin(pixmap);
painter.drawImage(0,0,rawImg);
painter.end();
pixmapItem->setPixmap(*pixmap);
ui->liveFeedView->setScene(scene);
qDebug() << "File updated: " << i;
}
i++;
if(rawImg.loadFromData(imgData[i]))
{
QPainter painter;
painter.begin(pixmap);
painter.drawImage(0,0,rawImg);
painter.end();
pixmapItem->setPixmap(*pixmap);
ui->liveFeedView->setScene(scene);
qDebug() << "File updated: " << i;
}
i++;
To copy to clipboard, switch view to plain text mode
Bookmarks