Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved]Keep strict alignment on the icon-items of the listwidget?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alexandros
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexandros
      wrote on last edited by
      #2

      @QListWidgetItem setSizeHint()@ did the job !

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved