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. Iconview text location
QtWS25 Last Chance

Iconview text location

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 755 Views
  • 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.
  • S Offline
    S Offline
    samdol
    wrote on last edited by p3c0
    #1

    alt text

    I created IconView of pixmap files using QListView and set the followings

    QListView* iconview2=new QListView;
    int iconSize_int=128;
    iconView2->setResizeMode(QListView::Adjust);
    iconView2->setMovement(QListView::Snap);
    iconView2->setViewMode(QListView::IconMode);
    iconView2->setUniformItemSizes(true);
    iconView2->setSelectionMode( QAbstractItemView::ExtendedSelection );
    iconView2->setStyleSheet("QListView::item:deselected { border: 1px
    solid black; border-radius: 6px; color: black;} QListView::item:selected
    {background: white; border: 4px solid orange;}");
    iconView2->setIconSize(QSize(iconSize_int,iconSize_int));
    iconView2->setGridSize(QSize(iconSize_int+30,iconSize_int+30));
    iconView2->setMinimumWidth(iconSize_int+38);
    

    You can check the output of this in the attachment.
    Instead of putting text inside border like this,
    can I put the text outsied border such as at T1, T2, T3, ....?

    mrjjM 1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @samdol This will be possible by creating custom delegate using QStyledItemDelegate and draw them manually.

      157

      1 Reply Last reply
      1
      • S samdol

        alt text

        I created IconView of pixmap files using QListView and set the followings

        QListView* iconview2=new QListView;
        int iconSize_int=128;
        iconView2->setResizeMode(QListView::Adjust);
        iconView2->setMovement(QListView::Snap);
        iconView2->setViewMode(QListView::IconMode);
        iconView2->setUniformItemSizes(true);
        iconView2->setSelectionMode( QAbstractItemView::ExtendedSelection );
        iconView2->setStyleSheet("QListView::item:deselected { border: 1px
        solid black; border-radius: 6px; color: black;} QListView::item:selected
        {background: white; border: 4px solid orange;}");
        iconView2->setIconSize(QSize(iconSize_int,iconSize_int));
        iconView2->setGridSize(QSize(iconSize_int+30,iconSize_int+30));
        iconView2->setMinimumWidth(iconSize_int+38);
        

        You can check the output of this in the attachment.
        Instead of putting text inside border like this,
        can I put the text outsied border such as at T1, T2, T3, ....?

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @samdol

        Here is small sample of a Delegate
        http://3adly.blogspot.dk/2013/09/qt-custom-qlistview-delegate-with-word.html

        and the more involved sample
        http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html

        1 Reply Last reply
        3

        • Login

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