Results 1 to 11 of 11

Thread: QModelIndex problem!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Posts
    38
    Thanks
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QModelIndex problem!

    I incorporated the following example's methods into my code!
    Qt Code:
    1. #include <QtCore>
    2. #include <QtGui>
    3.  
    4. class Inserter : public QObject {
    5. public:
    6. Inserter(QStandardItemModel *m) : QObject() {
    7. model = m;
    8. }
    9. protected:
    10. void timerEvent(QTimerEvent *e){
    11. QString str = QDateTime::currentDateTime().toString();
    12. model->appendRow(new QStandardItem(str));
    13. }
    14. private:
    15. };
    16.  
    17. int main(int argc, char **argv){
    18. QApplication app(argc, argv);
    19. model.setColumnCount(1);
    20. lv.setModel(&model);
    21. lv.show();
    22. Inserter ins(&model);
    23. ins.startTimer(1000);
    24. return app.exec();
    25. }
    To copy to clipboard, switch view to plain text mode 

    The entries show up OK whilst in the vicinity of the starting code!

    However off in a thread I am doing the same code:

    Qt Code:
    1. QString qstr("landon 2nd");
    2.  
    3. model->appendRow(new QStandardItem(qstr));
    To copy to clipboard, switch view to plain text mode 

    However, I get the following errors at run time and no entry:

    Qt Code:
    1. QObject::connect: Cannot queue arguments of type 'QModelIndex'
    2. (Make sure 'QModelIndex' is registered using qRegisterMetaType().)
    3. QObject::connect: Cannot queue arguments of type 'QModelIndex'
    4. (Make sure 'QModelIndex' is registered using qRegisterMetaType().)
    To copy to clipboard, switch view to plain text mode 

    Somehow the thread is not connected to the QModelIndex used at the beginning

    I am feverishly researching the matter whilst reading about MVC.

    qRegisterMetaType<QString>(); --->>>didn't work!
    Last edited by landonmkelsey; 22nd August 2008 at 06:19. Reason: later thought

Similar Threads

  1. QSql*Model + QTreeView : make a tree
    By punkypogo in forum Qt Programming
    Replies: 18
    Last Post: 24th October 2008, 18:14
  2. Problem with TreeView
    By init2null in forum Qt Programming
    Replies: 8
    Last Post: 25th May 2008, 09:56
  3. QAbstractItemModel newbie question
    By okellogg in forum Qt Programming
    Replies: 14
    Last Post: 18th February 2008, 12:30
  4. Problem: QThead and QTableview
    By ederbs in forum Qt Programming
    Replies: 5
    Last Post: 9th November 2007, 10:17
  5. Replies: 6
    Last Post: 21st September 2007, 13:51

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.