Important: Please read the Qt Code of Conduct -

Pyqt5: Load sqlite3 database to QListWidget

  • Hello,
    I am trying to load a column from my sqlite3 table database into my QListWidget.
    Then once the user selects an item from the list, the LineEdits beneath the list will auto populate with information from the database that's linked with the item in the column selected in the list.
    Could anyone guide me in the right direction?

    Edit: I managed to display the content using:

            conn = sqlite3.connect('Main_Database.db')
            curser= conn.cursor()
            curser.execute("SELECT Name , Type FROM Findings")
            hu= curser.fetchall()
            for i in range(len(hu)):
                item= QtWidgets.QListWidgetItem(hu[i][0])

    I just need it to send whatever item it highlights in the Qlistwidget to the line edits field beneath

  • This post is deleted!

  • Lifetime Qt Champion


    Use the currentItemChanged signal and populate the line edit in a slot connected to that signal.

    Out of curiosity, did you saw that there's the QtSql module ?

Log in to reply