[solved]Keep strict alignment on the icon-items of the listwidget?



  • Hi there!

    I have a listwidget where the user can add icon files. I show these files inside my listwidget as icon-items (my listwidget's viewmode is IconMode). Each of the items has as text its basename (e.g. if the path to the image is /home/alex/Pictures/mypic.jpg, then the text of the corresponding item will be mypic.jpg).

    I want to strictly show on each line a specific number of items. The problem exists when there are images with basename short and others with very long. Then, the listwidget, because I've set @ui->listWidget->setUniformItemSizes(true);@ chooses to add one item per line, only because the basename of specific items are very long.

    What I want to do is to crop each basename (the listwidget already does it to specific items but not to items with very long text) if it is too long and have a strict number of items per line.

    Each of my items has
    @item->setTextAlignment(Qt::AlignCenter);@

    Here are some pictures indicating the problem:

    How I want it to be, and how it is when the basenames are quite short and don't differ very much from each other: http://i.imgur.com/iWcH8.png

    What the problem is, when I have both long and short basenames: http://i.imgur.com/0NyMO.png

    I want the long basenames to be shorted, as well. I don't really get why the listwidget doesn't crop the long basenames while it does it to some much shorter ones.

    Thanks in advance!



  • @QListWidgetItem setSizeHint()@ did the job !


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.