Results 1 to 7 of 7

Thread: SQL Query Organization

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanked 342 Times in 324 Posts

    Default Re: SQL Query Organization

    So, it is better to write a custom model for each view or just use regular widgets e.g. qTableWidget to present the data?
    I don't know, it depends on the application. Maybe for your needs it will be just fine to use a simple table widget. I'm not a specialist on table view/model things, so maybe someone else will have some hints for you.
    My point is, if you hardcode db access with queries you may find it inconvenient in some cases. For example, your version of "GetUser" method could be uncomfortable if we have to present user details in a labels or set of line edits for editing:
    Qt Code:
    1. // here you can see 'GetUser' method name is not very self-explanatory
    2. QSqlQuery query = db.GetUser(id);
    3. ui.label_name->setText(query.value("name").toString());
    4. ui.label_address->setText(query.value("address").toString());
    5.  
    6. vs.
    7.  
    8. User user = db.GetUser(id);
    9. ui.label_name->setText(user.name());
    10. ui.label_address->setText(user.address());
    11. // etc
    To copy to clipboard, switch view to plain text mode 

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

    dk (11th January 2014)

Similar Threads

  1. Qt Creator Subfolder Organization
    By hiead in forum Newbie
    Replies: 3
    Last Post: 21st October 2013, 00:50
  2. Replies: 2
    Last Post: 13th January 2011, 18:36
  3. About tree organization...
    By Patrick Sorcery in forum Newbie
    Replies: 2
    Last Post: 3rd September 2010, 07:43
  4. SQL query
    By JD2000 in forum Newbie
    Replies: 4
    Last Post: 1st December 2009, 14:21

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.