Results 1 to 1 of 1

Thread: Using QTableWidgetItem to open an image

  1. #1
    Join Date
    Jul 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Using QTableWidgetItem to open an image

    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?




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

    Qt Code:
    1. void Window::showFiles(const QDir &directory, const QStringList &files)
    2. {
    3. for (int i = 0; i < files.size(); ++i) {
    4. QFile file(directory.absoluteFilePath(files[i]));
    5. qint64 size = QFileInfo(file).size();
    6.  
    7. QTableWidgetItem *fileNameItem = new QTableWidgetItem(files[i]);
    8. QTableWidgetItem *sizeItem = new QTableWidgetItem(tr("%1 KB") .arg(int((size + 1023) / 1024)));
    9.  
    10. int row = filesTable->rowCount();
    11. filesTable->insertRow(row);
    12. filesTable->setItem(row, 0, fileNameItem);
    13. filesTable->setItem(row, 1, sizeItem);
    14. }
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 


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

    Qt Code:
    1. void Window::open()
    2. {
    3. QWidget* img = new QWidget;
    4.  
    5.  
    6. img->show();
    7. }
    To copy to clipboard, switch view to plain text mode 

    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 )
    Last edited by frowde; 10th July 2011 at 18:00.

Similar Threads

  1. Replies: 1
    Last Post: 2nd December 2010, 15:01
  2. Replies: 3
    Last Post: 25th August 2010, 12:39
  3. Open a image from the QTableWidget
    By qtlinuxnewbie in forum Newbie
    Replies: 4
    Last Post: 6th March 2010, 05:58
  4. IE6 fails to open image by ftp
    By sinha.ashish in forum Qt Programming
    Replies: 4
    Last Post: 14th April 2008, 13:37
  5. Open image in full screen
    By jeetu_happy in forum Qt Programming
    Replies: 3
    Last Post: 23rd January 2007, 09:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.