Results 1 to 1 of 1

Thread: Display icons with text on a listwidget uniformly

  1. #1
    Join Date
    Apr 2016
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Display icons with text on a listwidget uniformly

    Hi,

    I add thumbanil images to a list widget and display the same in an icon mode along with text. However, due to the aspect ratio of the thumnails , i get the images up and down and not in a uniform line. Could you please help me ? I have attached the image of how it is now and how i want it to be

    HOW IT IS NOW
    listWidget.png

    HOW IT SHOULD LOOK

    menu_bg.png

    Snippet of how i add the files to the list widget

    Qt Code:
    1. // list the files in the list widget in the icon mode
    2. for (int i=1; i<imgList.size(); ++i)
    3. {
    4. QSize grid(150,150);
    5. QString imgPath = scaledDirPath.absoluteFilePath(imgList[i]);
    6. ui->FilesList->setMovement(QListWidget::Static);
    7. ui->FilesList->setViewMode(QListWidget::IconMode);
    8. ui->FilesList->setWordWrap(true);
    9. QString origImageName = (imgList[i].remove("_scaled", Qt::CaseSensitive));
    10. QListWidgetItem *item = new QListWidgetItem(QIcon(imgPath),origImageName);
    11.  
    12. item->setTextAlignment(Qt::AlignBottom);
    13.  
    14. ui->FilesList->setGridSize(grid);
    15.  
    16. ui->FilesList->addItem(new QListWidgetItem(QIcon(imgPath),origImageName));
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 
    Any help is appreciated

    Thanks
    Gayathri
    Last edited by anda_skoa; 14th April 2016 at 11:18. Reason: missing [code] tags

Similar Threads

  1. Replies: 4
    Last Post: 7th December 2011, 09:41
  2. Custom ListWidget(QCheckBox + Icon + Text)
    By nrabara in forum Newbie
    Replies: 6
    Last Post: 13th May 2010, 06:35
  3. Text Alignment in a ListWidget
    By Krish_ng in forum Qt Programming
    Replies: 2
    Last Post: 21st July 2007, 02:19
  4. Easiest way to display icons in a table
    By ghorwin in forum Qt Programming
    Replies: 3
    Last Post: 19th March 2007, 13:09
  5. Rightjustify text in listwidget
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2006, 10:17

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.