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. I want to display text and image inside the listwidget (as thumbnail)
Forum Updated to NodeBB v4.3 + New Features

I want to display text and image inside the listwidget (as thumbnail)

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 2.5k 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
    amarism
    wrote on last edited by
    #1

    I have a listwidget and i am making the listwidget as a thumbnail of the combination as text and image but the sequence of this is text followed by the image. But I am getting the sequence as image followed by text. I am using this one code for this :

                            listWidget->addItem(new QListWidgetItem(QIcon(QPixmap::fromImage(Image)),String));
    

    also, I am attaching the image view for this:

    0_1532082703331_Thumnailimagetext.png

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      hi
      so question is
      How do i get the text on top of image or ?

      A 1 Reply Last reply
      1
      • mrjjM mrjj

        hi
        so question is
        How do i get the text on top of image or ?

        A Offline
        A Offline
        amarism
        wrote on last edited by amarism
        #3

        @mrjj yes but an index of listwidget is same for text and image (here the only 6 index is there, but when I try to put text and image as an item then the listwidget index takes 1 index for everyone

        mrjjM 1 Reply Last reply
        0
        • A amarism

          @mrjj yes but an index of listwidget is same for text and image (here the only 6 index is there, but when I try to put text and image as an item then the listwidget index takes 1 index for everyone

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

          @amarism
          Im not sure what you mean with 1 index.

          Each item has text and icon.

          A 1 Reply Last reply
          0
          • mrjjM mrjj

            @amarism
            Im not sure what you mean with 1 index.

            Each item has text and icon.

            A Offline
            A Offline
            amarism
            wrote on last edited by
            #5

            @mrj I am taking 6 images. So, the index is from (0-5). But when I put text and image as item then all item taking 1-1 index I want too set the listwidget index equal to a number of the image.

            mrjjM 1 Reply Last reply
            0
            • A amarism

              @mrj I am taking 6 images. So, the index is from (0-5). But when I put text and image as item then all item taking 1-1 index I want too set the listwidget index equal to a number of the image.

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

              @amarism
              well
              listWidget->addItem(new QListWidgetItem ..
              should handle that automtically.

              A 1 Reply Last reply
              2
              • mrjjM mrjj

                @amarism
                well
                listWidget->addItem(new QListWidgetItem ..
                should handle that automtically.

                A Offline
                A Offline
                amarism
                wrote on last edited by
                #7

                @mrjj This one method
                QListWidgetItem(const QIcon & icon, const QString & text, QListWidget * parent = 0, int type = Type)
                but i want to take item value like ( Text and Image).

                mrjjM 1 Reply Last reply
                0
                • A amarism

                  @mrjj This one method
                  QListWidgetItem(const QIcon & icon, const QString & text, QListWidget * parent = 0, int type = Type)
                  but i want to take item value like ( Text and Image).

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

                  @amarism
                  but its just
                  Icon and text. why should that matter ?

                  1 Reply Last reply
                  0
                  • mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by mrjj
                    #9

                    Hi
                    Try setting
                    item->setTextAlignment(Qt::AlignTop);
                    and see if that works.

                    Update: it wont. still under when icon mode.

                    1 Reply Last reply
                    0
                    • mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by mrjj
                      #10

                      Hi
                      I could be wrong but i think to have text over, you need a delegate and draw it.
                      (unless someone knows how to make it use TextAlignment in iconmode)

                      https://forum.qt.io/topic/92857/icon-in-corner-of-qstandarditem/5

                      the SmallIconDelegate should be excellent starting point.

                      start with
                      http://doc.qt.io/qt-5/qitemdelegate.html

                      1 Reply Last reply
                      1

                      • Login

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