Results 1 to 3 of 3

Thread: Display Images in a TREEVIEW

  1. #1
    Join Date
    Mar 2010
    Posts
    54
    Qt products
    Qt/Embedded
    Platforms
    Symbian S60

    Default Display Images in a TREEVIEW

    Hi All

    I have a function where I am able to browse through specified directory (that contain images)

    /************************************************** *****************/
    void FrameDisplay::BrowseAndShow()
    {
    QDir dir("/home/kamlesh/Gall/GALL/images");
    dir.setFilter(QDir::Files);
    window = new QWidget;
    foreach( const QFileInfo& entry, dir.entryInfoList( QStringList()<< "*.png", QDir::Files) )
    {
    QString imgName = entry.fileName();
    QGridLayout* grid = new QGridLayout;
    QLabel* label = new QLabel(this);
    label->setPixmap(QPixmap(imgName));
    grid->addWidget(label);
    window->setLayout(grid);
    window->setGeometry(20,20,20,30);
    window->show();

    }

    }

    /************************************************** ****************/

    I need a way to display the images in a treeview structure e.g

    /****************************************/

    image1 image2
    filename filename

    image3 image4
    filename filename

    /****************************************/

    How should I go about it?
    Attached is the application GALL.zip and the macos style pdf for reference
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2008
    Location
    Marslev, Denmark
    Posts
    31
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Display Images in a TREEVIEW

    Create a tree model (*) and use Qt:ecorationRole in data() to set the icon.

    From your pdf file, I'm not sure if you can get away with a list model, though. It's worth trying, since those are a lot easier than tree models.

    (*) This is in itself quite difficult. Look at the Qt docs for info on how to do that. And take heart by knowing that you will be very pleased with the model and your code once it works.
    Bo Thorsen, Viking Software
    Qt applications on Linux and Windows

  3. #3
    Join Date
    Mar 2010
    Posts
    54
    Qt products
    Qt/Embedded
    Platforms
    Symbian S60

    Default Re: Display Images in a TREEVIEW

    I need a small example of table model
    And secondly the images to be displayed are from a directory. There fore, how can I create a table for the same.
    Last edited by kamlmish; 2nd December 2010 at 06:37.

Similar Threads

  1. How to display DDS images?
    By jamsession in forum Qt Programming
    Replies: 5
    Last Post: 12th June 2013, 22:18
  2. Display ToolTip when cibling a TreeView Cell
    By mourad in forum Qt Programming
    Replies: 0
    Last Post: 2nd November 2010, 08:33
  3. How do I display a list of images?
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 23rd November 2007, 08:49
  4. Is there any way to synchronize the display of images
    By kiransu123 in forum General Programming
    Replies: 2
    Last Post: 17th March 2007, 20:50
  5. Display animated images
    By suresh in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2007, 21:53

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.