Results 1 to 2 of 2

Thread: Displaying image though Qtablewidget

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

    Default Displaying image though Qtablewidget

    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

    Qt Code:
    1. void Window::open(int row, int /* column */)
    2. {
    3.  
    4. QTableWidgetItem *item = filesTable->item(row, 0);
    5. QDir (currentDir.absoluteFilePath(item->text()));
    6.  
    7. QUrl dir = QUrl::fromLocalFile(currentDir.absoluteFilePath(item->text()));
    8. qDebug() << QDesktopServices::openUrl(dir);
    9.  
    10. QGraphicsScene *scn = new QGraphicsScene( w );
    11.  
    12. w->setScene( scn );
    13. QPixmap pix (dir);
    14. scn->addPixmap( pix );
    15. w->show();
    16. }
    To copy to clipboard, switch view to plain text mode 


    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.

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

    Default Re: Displaying image though Qtablewidget

    I've got a bit further but it still wont display an image because of the QString =path

    Qt Code:
    1. void Window::open(int row, int /* column */)
    2. {
    3. QTableWidgetItem *item = filesTable->item(row, 0);
    4.  
    5.  
    6. QString path;
    7. path = (currentDir.absoluteFilePath(item->text()) );
    8.  
    9. QGraphicsScene *scn = new QGraphicsScene( w );
    10. w->setScene( scn );
    11.  
    12. QPixmap pix (path);
    13. scn->addPixmap( pix );
    14. w->show();
    15. }
    To copy to clipboard, switch view to plain text mode 

    can anyone help me

Similar Threads

  1. Displaying an image
    By seltra in forum Newbie
    Replies: 2
    Last Post: 3rd October 2010, 19:30
  2. as displaying an image in a mdi?
    By Lycus HackerEmo in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2010, 12:14
  3. Displaying image
    By Rui in forum Newbie
    Replies: 1
    Last Post: 20th June 2009, 21:15
  4. Regarding displaying image in grid.
    By prajna in forum Newbie
    Replies: 3
    Last Post: 20th February 2009, 19:39
  5. Displaying a portion of an image
    By tas in forum Qt Programming
    Replies: 4
    Last Post: 28th November 2008, 03:09

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.