Results 1 to 7 of 7

Thread: auto checkox fresh in qtreeview problem.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2008
    Posts
    10
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default auto checkox fresh in qtreeview problem.

    i have a custom model, and want to achieve the effect in attachment pic.
    now i can react on the setdata method in model,like below:
    //-------------------------------------------------
    bool TorgTreeModel::setData( const QModelIndex & index, const QVariant & value, int role /*= Qt::EditRole */ )
    {

    if (!index.isValid())
    return true;


    TorgTreeItem *item = static_cast<TorgTreeItem*>(index.internalPointer() );

    if (role == Qt::CheckStateRole && index.column() ==0)
    {
    item->setCheckState( static_cast<Qt::CheckState>(value.toUInt()));
    // emit dataChanged(createIndex(0,0,m_root_item),
    // createIndex(m_root_item->childCount()-1,0,m_root_item));
    return true;
    }

    return QAbstractItemModel::setData(index,value,role);
    }

    i can change all checkstate of the model data for the right value, but i can't tell qtreeview to refresh the new data.
    i use beginresetmodel/endresetmodel ,it does refresh,but qtreeview not keep the display layout.
    now with my code, when i switch to other program and back, qtreeview display ok, but this is not the solution.

    is there any other convenient way to tell the qtreeview update the display?
    or there is other way to achieve the same effect?
    thanks in advance!
    Attached Images Attached Images

Similar Threads

  1. Replies: 3
    Last Post: 12th February 2010, 10:10
  2. A very fresh new Qt programmer =)
    By ZikO in forum Installation and Deployment
    Replies: 5
    Last Post: 4th December 2009, 15:24
  3. compiling hello world after fresh install fails
    By kvesi in forum Installation and Deployment
    Replies: 3
    Last Post: 19th September 2008, 13:55
  4. Program not compiling on Fresh install of Leopard
    By dvmorris in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 10:22
  5. I'm a fresh,how this problem could be resolved?
    By defyer in forum Qt Programming
    Replies: 6
    Last Post: 16th July 2007, 08:04

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.