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. Pyqt5: Load sqlite3 database to QListWidget

Pyqt5: Load sqlite3 database to QListWidget

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.0k 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.
  • D Offline
    D Offline
    DouglinhasZN
    wrote on last edited by DouglinhasZN
    #1

    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()
            self.FindingsListWidget_Window.clear()
            for i in range(len(hu)):
                item= QtWidgets.QListWidgetItem(hu[i][0])
                self.FindingsListWidget_Window.addItem(item)
    

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

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DouglinhasZN
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        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 ?

        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
        1

        • Login

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