Results 1 to 5 of 5

Thread: List or Table or Grid or Tree or ... ?? What to pick?

  1. #1
    Join Date
    Sep 2006
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default List or Table or Grid or Tree or ... ?? What to pick?

    I'm looking for a Qt equivalent of Mac OS X's Data Browser API.

    There seem to be a few different options (List, Grid, Tree, Table) but none of them seem to offer everything that I need in one place.

    Here are my list of requirements:

    1. Resizable, rearrangeable and sortable columns
    2. Ability to display and edit checkbox, combobox (menu in Mac-land), text, icon, per column (no edit required for icons)
    3. Ability to disable a single row, preventing selection & editing

    If anyone here knows the Data Browser API from Mac OS X then you'll know what I'm after

    Is this available? If so, where do I start? I've already had a number of false starts...

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: List or Table or Grid or Tree or ... ?? What to pick?

    You can use QTableView or QTreeView to achieve all that.

  3. #3
    Join Date
    Sep 2006
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: List or Table or Grid or Tree or ... ?? What to pick?

    Thanks for your reply, but unfortunately this didn't help me.

    To give you an example of the problem I face, let me explain what I have found so far:

    In comparing the QTreeView to QTableView, it appears that Tree provides resizable, reorderable and sortable columns with the correct platform appearance. Table, on the other hand, only offers resizable columns. However, Table seems to provide built-in checkbox, combobox and text in-place editing and display, whereas Tree view does not.

    I did try working with a Tree view but found that although I can specify delegate checkbox and combobox editors, it's not so easy to use the same widgets to just display the data. I did manage to get a checkbox to display via a custom 'paint' but there were problems such as the background not being correct when the row was selected. Worse still, I couldn't find a way of just drawing a combobox.

    Am I missing something or does everyone override the base views heavily to get this kind of functionality?

    Thanks again.

  4. #4
    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: List or Table or Grid or Tree or ... ?? What to pick?

    Quote Originally Posted by Martin
    Table seems to provide built-in checkbox, combobox and text in-place editing and display, whereas Tree view does not.
    Not correct. Both can have exactly the same editors. QTableView and QTreeView use the same delegate, QStandardItemDelegate that is, by default. QStandardItemDelegate offers different kind of editors depending on the type of the variant data:
    - QComboBox for booleans
    - QSpinBox for integers (both signed and unsigned)
    - QDoubleSpinBox for doubles
    - QDateTimeEdit for datetimes
    - QDateEdit for dates
    - QTimeEdit for times
    (- QLabel for pixmaps)
    - QLineEdit otherwise

    The corresponding editor appears when your model returns the data in appropriate format. A common mistake is to insert all data as text. By this way you'll end up always having a QLineEdit as the editor.

    For checkable items, the model needs to return appropriate flag for indexes you want to be checkable. Items are not checkable by default, you can override QAbstractItemModel::flags() and return Qt::ItemIsUserCheckable among the other needed flags to make items checkable. The same model can be used in any view (QTableView, QTreeView..) and they appear as checkable.

    Am I missing something or does everyone override the base views heavily to get this kind of functionality?
    Hardly. All you have described IS supported kind of "out of the box".
    J-P Nurmi

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: List or Table or Grid or Tree or ... ?? What to pick?

    Quote Originally Posted by Martin
    Am I missing something or does everyone override the base views heavily to get this kind of functionality?
    I suggest you familiarise yourself with model-view programming with Qt4, especially with the concept of roles and delegates.

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.