Results 1 to 2 of 2

Thread: Data from TableModel and into Text Edit

  1. #1
    Join Date
    Sep 2009
    Posts
    34
    Thanks
    28
    Qt products
    Qt4
    Platforms
    MacOS X

    Question Data from TableModel and into Text Edit

    Hi guys,

    I'm wondering how to copy the data on a field of a QSqlTableModel into a TextEdit. Any ideas? Please post some code.

    Thanks in advance,

  2. #2
    Join Date
    Nov 2006
    Location
    Saudi Arabia
    Posts
    18
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Data from TableModel and into Text Edit

    try like this :

    Qt Code:
    1. model.setTable("employee");
    2.  
    3. // to get the value of the field "name" in the 4th record (also you can loop for all the records):
    4. QString name = model.record(4).value("name").toString();
    5.  
    6. textEdit->append(name);
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to SudaNix for this useful post:

    Nefastious (16th September 2009)

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.