Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to copy all items from one QListWidget to another?
Qt 6.11 is out! See what's new in the release blog

How to copy all items from one QListWidget to another?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 3 Posters 2.9k 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
    Sriu1
    wrote on last edited by
    #1

    I have created a QList of QListWidget and have appended some QListWidgets.I also have a QListWidget in mainwindow ui.
    I want a particular QListWidget from QList to be displayed in the ui.How can it be done?Plz suggest.

    J.HilkJ 1 Reply Last reply
    0
    • S Sriu1

      I have created a QList of QListWidget and have appended some QListWidgets.I also have a QListWidget in mainwindow ui.
      I want a particular QListWidget from QList to be displayed in the ui.How can it be done?Plz suggest.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Sriu1
      One does not simply copy a QListWidget!
      alt text

      In fact its nearly impossible, as it inherits from QObject.

      But I think you actually want to do something different, could you explain it in more detail? Prefered with a code example.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • S Offline
        S Offline
        Sriu1
        wrote on last edited by Sriu1
        #3

        I'm creating a playlist for video,audio,image.I have created a QList<QListWidget*> list;
        and I have appended 3 QListWidgets to this.I have a QComboBox in ui when video option is selected I want to display video QListWidget.

        Btw found a GOT fan here :)

        jsulmJ 1 Reply Last reply
        0
        • S Sriu1

          I'm creating a playlist for video,audio,image.I have created a QList<QListWidget*> list;
          and I have appended 3 QListWidgets to this.I have a QComboBox in ui when video option is selected I want to display video QListWidget.

          Btw found a GOT fan here :)

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Sriu1 said in How to copy all items from one QListWidget to another?:

          want to display video QListWidget

          display where?
          Can you be more specific?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sriu1
            wrote on last edited by
            #5

            In the ui I have a QListWidget created in design mode. I want to display all the items from a particular QListWidget from the QList into the QListWidget which is created in the design mode.

            jsulmJ 1 Reply Last reply
            0
            • S Sriu1

              In the ui I have a QListWidget created in design mode. I want to display all the items from a particular QListWidget from the QList into the QListWidget which is created in the design mode.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by jsulm
              #6

              @Sriu1 Then iterate over the items of that QListWidget and for each item create a new QListWidgetItem with same values and add it to the other QListWidget...
              There is even a copy constructor: http://doc.qt.io/qt-5/qlistwidgetitem.html#QListWidgetItem-3
              Or http://doc.qt.io/qt-5/qlistwidgetitem.html#clone
              ...

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              3
              • J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                Additionaly to what @jsulm wrote, you might also want to look into QListView

                from your describtion, its seems more reasonable to manage/store one model and simply pass that to your different QListViews.


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                4

                • Login

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