How to get multiple selected Items from a QListwidget and save tha values in databases?
-
-
@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 .@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. -
@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. -
@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.@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? -
@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? -
@Stephen28 OK, so do so.
-
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.