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. How to get name of image from QlistWidget

How to get name of image from QlistWidget

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 564 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.
  • O Offline
    O Offline
    Osama_Billah
    wrote on last edited by
    #1

    Hi I have different images in QListWidget. I want that If I clicked on the images it show me the actual name.

    
        def add_images_to_TabWIdget(self):
    
            path = "C:/Users/OB/Desktop/DevoMech Project/data/thumdnail/"
            print(path)
    
            print(self.entries)
            filename = []
            i=0
            for entry in self.entries:
                filename.append(entry)
                print(filename[i])
                #entry = self.entries
            # print(entry)
            # a = (","  .join(entry))
            # print(a)
    
                item1 = QtWidgets.QListWidgetItem(QIcon(path + filename[i]), filename[i])
                self.dlistWidget.addItem(item1)
                return item1
                i += 1
    
        def item_images_clicked(self , item1):
    
            print("click {}".format(item1.text()))
    
    A 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You have to store the name by yourself in the QListWidgetItem e.g. with QListWidgetItem::setData()

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      O 2 Replies Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        You have to store the name by yourself in the QListWidgetItem e.g. with QListWidgetItem::setData()

        O Offline
        O Offline
        Osama_Billah
        wrote on last edited by
        #3

        @Christian-Ehrlicher I want to take the image name from the list

        1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          You have to store the name by yourself in the QListWidgetItem e.g. with QListWidgetItem::setData()

          O Offline
          O Offline
          Osama_Billah
          wrote on last edited by Osama_Billah
          #4

          @Christian-Ehrlicher all the names are store in the list. and from that list i input the images with the name. and I want that if someone clicked on that image it print the image name

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Osama_Billah said in How to get name of image from QlistWidget:

            I want to take the image name from the list

            Then store the index to the list in QListWidgetItem::data() so you can access it later on.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            4
            • O Osama_Billah

              Hi I have different images in QListWidget. I want that If I clicked on the images it show me the actual name.

              
                  def add_images_to_TabWIdget(self):
              
                      path = "C:/Users/OB/Desktop/DevoMech Project/data/thumdnail/"
                      print(path)
              
                      print(self.entries)
                      filename = []
                      i=0
                      for entry in self.entries:
                          filename.append(entry)
                          print(filename[i])
                          #entry = self.entries
                      # print(entry)
                      # a = (","  .join(entry))
                      # print(a)
              
                          item1 = QtWidgets.QListWidgetItem(QIcon(path + filename[i]), filename[i])
                          self.dlistWidget.addItem(item1)
                          return item1
                          i += 1
              
                  def item_images_clicked(self , item1):
              
                      print("click {}".format(item1.text()))
              
              A Offline
              A Offline
              anil_arise
              wrote on last edited by
              #6

              @Osama_Billah

              add line in add_images_to_TabWIdget(self):

              dlistWidget.itemClicked.connect(item_images_clicked)

              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