Results 1 to 4 of 4

Thread: [ Solved ] a QTableView/QAbstractTableModel problem, please help

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    3
    Thanked 3 Times in 1 Post

    Default Re: a QTableView/QAbstractTableModel problem, please help

    thanks, I forgot the EditRole.

  2. #2
    Join Date
    Apr 2014
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: a QTableView/QAbstractTableModel problem, please help

    3q for your help! I do as you do!

    QVariant Model::data(const QModelIndex &index, int role) const
    {
    if (!index.isValid())
    return QVariant();

    if (role == Qt::TextAlignmentRole)
    {
    return int(Qt::AlignRight | Qt::AlignVCenter);
    }
    else if (role == Qt:isplayRole)
    {
    // problem solved, I forgot the Qt::EditRole
    return dataset[index.row()][index.column()];
    }
    else if(role == Qt::EditRole)
    {
    QString str = dataset[index.row()][index.column()];
    return str;
    }

    return QVariant();
    }

Similar Threads

  1. qabstracttablemodel/qtableview: vector data columns
    By xyfix in forum Qt Programming
    Replies: 0
    Last Post: 15th September 2010, 13:51
  2. Replies: 4
    Last Post: 6th May 2009, 09:18
  3. Performance with QTableView and QAbstractTableModel
    By MBex in forum Qt Programming
    Replies: 3
    Last Post: 25th February 2009, 09:04
  4. Replies: 3
    Last Post: 29th January 2009, 09:38
  5. QAbstractTableModel for QTreeView?
    By Michiel in forum Qt Programming
    Replies: 5
    Last Post: 15th May 2007, 10:09

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.