Results 1 to 5 of 5

Thread: QTable - Date Base Problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: QTable - Date Base Problem

    just use QTableView & subclass QAbstractTableModel as your model.
    Look here how to do exactly.

    inside your model you can use any kind of datastructure you want:

    Qt Code:
    1. QVariant MyTableModel::data(const QModelIndex &index, int role) const
    2. {
    3. if (!index.isValid())
    4. return QVariant();
    5.  
    6. if (role == Qt::TextAlignmentRole)
    7. {
    8. return int(Qt::AlignRight | Qt::AlignVCenter);
    9. }
    10. else if(role == Qt::ToolTipRole)
    11. {
    12. return "hello"; // for example
    13. }
    14. else if (role == Qt::DisplayRole)
    15. {
    16. return myData[index.row()][index.column()]; // for example
    17. }
    18. return QVariant();
    19. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2007
    Posts
    8
    Qt products
    Qt3
    Platforms
    Unix/X11
    Thanks
    1

    Default Re: QTable - Date Base Problem

    sry, I didn't mention that I'm writing in qt3, but tnx so much!

Similar Threads

  1. Replies: 7
    Last Post: 15th April 2007, 02:39
  2. QTable resize problem with large tables
    By Robzzz in forum Newbie
    Replies: 3
    Last Post: 22nd May 2006, 15:13
  3. Problem with QTable
    By zlatko in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2006, 11:00

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.