Results 1 to 2 of 2

Thread: Simple DB app, some questions.

  1. #1
    Join Date
    Dec 2007
    Posts
    11
    Thanks
    4

    Question Simple DB app, some questions.

    Hi all, I'm doing a small database application and would like to ask if I'm doing well:

    1) The user should see some of the data stored in the table "members". This table contains a lot of details but the most interesting ones are "member num", "name", "surname 1", "surname 2" and "member id". Besides this 5, the user should see 2 more, generated at runtime from the "less-interesting" details (like for example, calculating the time between two periods of time).
    2) The user should be able to view extra information of the members, including again some that is not contained directly in the table, but generated from the data at runtime.
    3) Is the user sees any erroneus field he should be able to correct it.
    4) It should be possible to search.

    For achieving this, I'm using a QSqlRelationalTableModel, "assigned" to a QSortFilterProxyModel and this one viewed in a QTableView.

    My first doubt is about 1), because it seems that I cannot add dynamic columns, just hide or show the ones existing in the database. So, is SqlRelationalTableModel a bad selection for my purposes?

    For achieving 2), I thought that a QDialog could arise when the user double-clicks onto a given row. That QDialog would contain the "extended" information, and let the user modify it, so this idea would also accomplish 3)

    Last, for 4) I want to let the user decide if he wants to search in one of three posible manners, selectable by three exclusive radio buttons:
    * Name + surname1 + surname2
    * Member num
    * Member id
    The problem, is that QSortFilterProxyModel can only search one column at a time, or all of them, but there is no intermediate option. So what would be the best way of doing a search which affects 3 (or an arbitrary number of) columns?


    Any ideas, opinions and corrections about how to do this would be appreciated;
    thanks for reading

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Simple DB app, some questions.

    Quote Originally Posted by juannm View Post
    My first doubt is about 1), because it seems that I cannot add dynamic columns, just hide or show the ones existing in the database. So, is SqlRelationalTableModel a bad selection for my purposes?
    You can reimplement columnCount() and data() in either QSqlRelationalTableModel subclass or QSortFilterProxyModel subclass. If index passed to data() refers to a dynamic column you calculate data and return it, otherwise you call the base class implementation.

    For achieving 2), I thought that a QDialog could arise when the user double-clicks onto a given row. That QDialog would contain the "extended" information, and let the user modify it, so this idea would also accomplish 3)
    What about showing tooltips or a separate widget next to the view (a bit like in QColumnView)? A separate widget could even use QDataWidgetMapper to let user directly edit model data. I guess a popup dialog goes too but I like to avoid them myself.

    Last, for 4) I want to let the user decide if he wants to search in one of three posible manners, selectable by three exclusive radio buttons:
    * Name + surname1 + surname2
    * Member num
    * Member id
    The problem, is that QSortFilterProxyModel can only search one column at a time, or all of them, but there is no intermediate option. So what would be the best way of doing a search which affects 3 (or an arbitrary number of) columns?
    You can reimplement QSortFilterProxyModel::filterAcceptsRow() to apply custom filtering.
    J-P Nurmi

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

    juannm (20th August 2008)

Similar Threads

  1. Simple custom widget won't size properly
    By MrGarbage in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2007, 14:12
  2. Memory management questions (im new to Qt)
    By scarvenger in forum Qt Programming
    Replies: 2
    Last Post: 6th May 2007, 08:41
  3. simple questions. qt3 to qt4
    By impeteperry in forum Newbie
    Replies: 16
    Last Post: 3rd April 2006, 18:41
  4. 2 Questions about layouts
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 26th February 2006, 14:54
  5. Qt related questions and thoughts about getting job
    By AlexKiriukha in forum General Discussion
    Replies: 4
    Last Post: 26th January 2006, 13:25

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.