Results 1 to 6 of 6

Thread: Adding List of Images with filenames and a combobox for each

  1. #1
    Join Date
    Oct 2014
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Post Adding List of Images with filenames and a combobox for each

    Hi All,

    I need to display a list of images . This list contains images along with the image name specified below it along with a combobox.
    What is the best solution? Do i use a grid layout to place the items one below the other or use a QListWidget instead.
    I hope someone could help me with this.
    Thanks in advance!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Adding List of Images with filenames and a combobox for each

    How many images? Is the number variable or fixed?

    For a small number a vertical layout containing a custom widget per image, perhaps in a scroll area, might be appropriate.
    For a large or variable list of images a list widget with a customised delegate might be better suited.

  3. #3
    Join Date
    Oct 2014
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Adding List of Images with filenames and a combobox for each

    I have a 100 images and the number is fixed.
    How do i go about creating a customised delegate?


    Added after 1 18 minutes:


    Currently i have created a Listwidgetand added the items to the list using a for loop. The list widget is then added to vBoxLayout. But the list appears as a small box on the top left corner of the window. How do i make the contents fit to screen.
    Last edited by sRB; 2nd February 2015 at 06:13.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding List of Images with filenames and a combobox for each

    Quote Originally Posted by sRB View Post
    I
    Currently i have created a Listwidgetand added the items to the list using a for loop. The list widget is then added to vBoxLayout. But the list appears as a small box on the top left corner of the window. How do i make the contents fit to screen.
    That either means that the widget is not in a layout or that they layout is not set on the parent widget (or not added to a parent layout).

    Cheers,
    _

  5. #5
    Join Date
    Oct 2014
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Adding List of Images with filenames and a combobox for each

    I'm adding the list widget to the group box and then setting a scrollwidget for it and adding that to the layout. But still the problem persists.

    Here's my code:

    Qt Code:
    1. QVBoxLayout *vLayout = new QVBoxLayout(parent);
    2. QGroupBox *groupBox = new QGroupBox();
    3. QListWidget *list = new QListWidget();
    4.  
    5.  
    6. for()
    7. {
    8. list->setViewMode(QListView::ListMode);
    9. list->setIconSize(QSize(500,500));
    10. list->setResizeMode(QListView::Adjust);
    11. list->addItem(new QListWidgetItem(QIcon(filename),filename));
    12. }
    13.  
    14.  
    15. vLayout->addWidget(list);
    16.  
    17. groupBox->setLayout(vLayout);
    18. scrollArea = new QScrollArea(this);
    19.  
    20. QVBoxLayout *layout = new QVBoxLayout(parent);
    21. layout->addWidget(scrollArea);
    22. scrollArea->setWidget(groupBox);
    23. this->setLayout(layout);
    24.  
    25. this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    26. this->resize(1000,600);
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 2nd February 2015 at 20:38. Reason: missing [code] tags

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Adding List of Images with filenames and a combobox for each

    Give the group box a size explicitly. The scroll area will not resize the widget, just allow you to pan about if it becomes larger than the viewport.

Similar Threads

  1. Replies: 2
    Last Post: 30th January 2014, 13:05
  2. How to make combobox drop down list transparency?
    By ysilent in forum Qt Programming
    Replies: 0
    Last Post: 19th October 2011, 10:34
  3. Replies: 1
    Last Post: 23rd April 2011, 17:33
  4. Resize of ComboBox List Box
    By sivollu in forum Newbie
    Replies: 4
    Last Post: 2nd February 2010, 10:57
  5. Problem in displaying the ComboBox list
    By raghvendramisra in forum Qt Tools
    Replies: 4
    Last Post: 28th February 2008, 13:25

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.