Results 1 to 4 of 4

Thread: connecting issue with QAbstractItemModel

  1. #1
    Join Date
    Jul 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default connecting issue with QAbstractItemModel

    Hey,

    I have a QListView from which I obtain a QAbstractItemModel with list->model();

    After this, I want to connect the dataChanged signal to a custom QObject of mine:

    Qt Code:
    1. if( QObject::connect(model, SIGNAL(dataChanged (const QModelIndex , const QModelIndex ) ),
    2. customObject_,SLOT(onText(const QModelIndex , const QModelIndex )) ) )
    3. Proxy::write("SIGNAL SLOT connection successful");
    4. else
    5. Proxy::write("SIGNAL SLOT connection ERROR");
    To copy to clipboard, switch view to plain text mode 

    here is my custom object:
    Qt Code:
    1. class CustomObject : public QObject
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. CustomObject (QObject *parent);
    7. ~CustomObject ();
    8.  
    9. public slots:
    10. void onText(const QModelIndex & topLeft, const QModelIndex & bottomRight );
    11.  
    12. private:
    13.  
    14. };
    To copy to clipboard, switch view to plain text mode 
    what am I doing wrong? I have a cout in the onText function, but nothing is ever printed when the QListView is Changed.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: connecting issue with QAbstractItemModel

    have you made sure the connection succeeds?

  3. #3
    Join Date
    Jul 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: connecting issue with QAbstractItemModel

    yes the QObject::connect call returns true

  4. #4
    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: connecting issue with QAbstractItemModel

    What kind of model is this?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to make QAbstractItemModel 's data checkable
    By nifei in forum Qt Programming
    Replies: 12
    Last Post: 1st April 2013, 19:52
  2. Replies: 8
    Last Post: 27th April 2009, 19:19
  3. dynamic signal connecting
    By donglebob in forum Qt Programming
    Replies: 4
    Last Post: 19th November 2008, 09:58

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.