PDA

View Full Version : Using QTableWidgetItem to open an image



frowde
10th July 2011, 18:49
Hi I'm new to this but I'm trying to use QTableWidgetItem in relation to opening an image with it I would like it to once clicked on the file in the table you press open and opens the image on a different window.
So far I have to it to open a blank new window when you press open file but how do you get it to read the image file and display it?

http://i175.photobucket.com/albums/w123/frowde/image.png


This is for displaying the files in the folder its looking in



void Window::showFiles(const QDir &directory, const QStringList &files)
{
for (int i = 0; i < files.size(); ++i) {
QFile file(directory.absoluteFilePath(files[i]));
qint64 size = QFileInfo(file).size();

QTableWidgetItem *fileNameItem = new QTableWidgetItem(files[i]);
QTableWidgetItem *sizeItem = new QTableWidgetItem(tr("%1 KB") .arg(int((size + 1023) / 1024)));

int row = filesTable->rowCount();
filesTable->insertRow(row);
filesTable->setItem(row, 0, fileNameItem);
filesTable->setItem(row, 1, sizeItem);
}

}



This is what I've got for the open button for the monent



void Window::open()
{
QWidget* img = new QWidget;


img->show();
}


Any help is appreciated I've been going nuts trying to do this
Thanks in advance

P.S
Also I've been looking at these

QTableWidgetItem::isSelected ()
QTableWidgetItem::write ( QDataStream & out )
QTableWidgetItem::read ( QDataStream & in )