PDA

View Full Version : Displaying image though Qtablewidget



frowde
11th July 2011, 17:46
Hi I'm trying to display an image on a new window once you double click on the file
how do you make it able to click on a different file and display it in the new window



void Window::open(int row, int /* column */)
{

QTableWidgetItem *item = filesTable->item(row, 0);
QDir (currentDir.absoluteFilePath(item->text()));

QUrl dir = QUrl::fromLocalFile(currentDir.absoluteFilePath(it em->text()));
qDebug() << QDesktopServices::openUrl(dir);

QGraphicsView* w = new QGraphicsView();
QGraphicsScene *scn = new QGraphicsScene( w );

w->setScene( scn );
QPixmap pix (dir);
scn->addPixmap( pix );
w->show();
}



So far the code opens a new blank window each time I double click on a image file but how do you get the path from QUrl to link to Qpixmap and display the new image each time you click on a different image file.

frowde
12th July 2011, 17:15
I've got a bit further but it still wont display an image because of the QString =path



void Window::open(int row, int /* column */)
{
QTableWidgetItem *item = filesTable->item(row, 0);


QString path;
path = (currentDir.absoluteFilePath(item->text()) );

QGraphicsView* w = new QGraphicsView();
QGraphicsScene *scn = new QGraphicsScene( w );
w->setScene( scn );

QPixmap pix (path);
scn->addPixmap( pix );
w->show();
}

can anyone help me :(