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 multiple selected Items from a QListwidget and save tha values in databases?
Forum Updated to NodeBB v4.3 + New Features

How to get multiple selected Items from a QListwidget and save tha values in databases?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 740 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.
  • S Offline
    S Offline
    Stephen28
    wrote on last edited by
    #1

    How to get multiple selected Items from a QListwidget and save in the database

    jsulmJ 1 Reply Last reply
    0
    • S Stephen28

      How to get multiple selected Items from a QListwidget and save in the database

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

      @Stephen28 There is https://doc.qt.io/qt-6/qlistwidget.html#selectedItems

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

      S 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Stephen28 There is https://doc.qt.io/qt-6/qlistwidget.html#selectedItems

        S Offline
        S Offline
        Stephen28
        wrote on last edited by
        #3

        @jsulm Yes., How can I save the list values in the single column of the database.
        Sorry this maybe a easy one.But I'm switching my career Mechanical from IT .

        jsulmJ 1 Reply Last reply
        0
        • S Stephen28

          @jsulm Yes., How can I save the list values in the single column of the database.
          Sorry this maybe a easy one.But I'm switching my career Mechanical from IT .

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

          @Stephen28 Did you already take a look at https://doc.qt.io/qt-6/qtsql-index.html ?
          Your question is vague, so it is not clear where exactly you need support.

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

          S 1 Reply Last reply
          1
          • jsulmJ jsulm

            @Stephen28 Did you already take a look at https://doc.qt.io/qt-6/qtsql-index.html ?
            Your question is vague, so it is not clear where exactly you need support.

            S Offline
            S Offline
            Stephen28
            wrote on last edited by
            #5

            @jsulm for example i have to select Multiple courses from listwidget to enroll.
            so assume i am selecting 3 courses. And I need to store the three courses in the single column in the database.

            JonBJ 1 Reply Last reply
            0
            • S Stephen28

              @jsulm for example i have to select Multiple courses from listwidget to enroll.
              so assume i am selecting 3 courses. And I need to store the three courses in the single column in the database.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @Stephen28
              And is the list widget already connected to a database?

              Sounds like you want to get the selected items in the list and then connect to a SQL database (QtSql.... classes) and store them there?

              What do you mean by " single column in the database"? 3 items should be stored in a column as 3 distinct rows in a table. If you want to store them all in a column but in one row then you will have to do something like join them together with , and store as a string?

              S 1 Reply Last reply
              0
              • JonBJ JonB

                @Stephen28
                And is the list widget already connected to a database?

                Sounds like you want to get the selected items in the list and then connect to a SQL database (QtSql.... classes) and store them there?

                What do you mean by " single column in the database"? 3 items should be stored in a column as 3 distinct rows in a table. If you want to store them all in a column but in one row then you will have to do something like join them together with , and store as a string?

                S Offline
                S Offline
                Stephen28
                wrote on last edited by
                #7

                @JonB yes.. I need join them together in a String with ,

                JonBJ 1 Reply Last reply
                0
                • S Stephen28

                  @JonB yes.. I need join them together in a String with ,

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @Stephen28 OK, so do so.

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

                    Hi,

                    Out of curiosity, what is your database schema ?
                    As already suggested by my fellows, you should have on entry per course rather than having the information stashed as a single entry.

                    Typically a table that stores the ID of the person with the ID of the course selected and thus as many rows as needed.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    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