Results 1 to 6 of 6

Thread: Extract data from db then pass it to qtreeview

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2012
    Posts
    8
    Qt products
    Platforms
    Windows
    Thanked 3 Times in 3 Posts

    Question Extract data from db then pass it to qtreeview

    Hi,
    I'm totally a newbie. I have this project in mind. I want to search data from my database and if it finds it, it will display the selected data to my QTreeView. I have already a query that can connect to my Postgresql Database. Here is the code:

    import sys
    from PyQt4.QtSql import *

    def createConnection():
    db = QSqlDatabase.addDatabase("QPSQL");
    db.setHostName("localhost")
    db.setPort(5432)
    db.setDatabaseName("db")
    db.setUserName("username")
    db.setPassword("password")
    ok = db.open()

    query = QSqlQuery()
    query.exec_("select * from itemlist;")
    return True

    This is the code for connecting to my database. My table for example is composed of pkey,itemcode,description and Quantity. I have a QLineEdit in my Gui. In that QLineEdit,it will search the ItemCode from my table and when it finds an item, it will automatically send that item data to my QTreeView with its details. How can this be possible. I hope you could help me. Please.

    Best Regards,
    Nethan

  2. The following user says thank you to nethanjavier for this useful post:


Similar Threads

  1. How to extract data from QFormLayout?
    By szisziszilvi in forum Qt Programming
    Replies: 5
    Last Post: 17th May 2011, 09:18
  2. Extract Item from the QTreeView
    By sajis997 in forum Qt Programming
    Replies: 2
    Last Post: 25th March 2011, 08:40
  3. extract data from photos
    By timmu in forum Qt Programming
    Replies: 1
    Last Post: 24th September 2009, 09:38
  4. How can I extract raw data from a QPixmap?
    By ricardo in forum Qt Programming
    Replies: 3
    Last Post: 16th September 2009, 08:31
  5. extract data from sqlTablemodel
    By peace_comp in forum Qt Programming
    Replies: 1
    Last Post: 13th May 2008, 19:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.