Results 1 to 3 of 3

Thread: in QAbstractItemView rowsAboutToBeRemoved() give wrong model index

  1. #1
    Join Date
    Mar 2010
    Posts
    63
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default in QAbstractItemView rowsAboutToBeRemoved() give wrong model index

    Hi
    ,I had impelemented QAbstractItemView and i m setting QStandarditemmodel as model.
    When i using removerow(0) in model,then i am not getting any correct index in rowsAboutToBeRemoved of Qabractitemview,
    But its look like row get delted before before calling slots.Please let me know how to get vaild index in rowsAboutToBeRemoved

  2. #2
    Join Date
    Mar 2010
    Posts
    63
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: in QAbstractItemView rowsAboutToBeRemoved() give wrong model index

    ANY IDEA about my problem or its a qt bug?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: in QAbstractItemView rowsAboutToBeRemoved() give wrong model index

    It's hard to help you since you didn't show us any of your code.

    This works fine for me:

    Qt Code:
    1. #include <QtGui>
    2.  
    3. class Dummy : public QObject {
    4. Q_OBJECT
    5. public:
    6. Dummy() : QObject() {}
    7. public slots:
    8. void check(const QModelIndex &parent, int start, int end) {
    9. qDebug() << Q_FUNC_INFO << start << end;
    10. }
    11. };
    12.  
    13. #include "main.moc"
    14.  
    15. int main(int argc, char **argv) {
    16. QCoreApplication app(argc, argv);
    17. QStandardItemModel model(4,2);
    18. Dummy d;
    19. QObject::connect(&model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), &d, SLOT(check(QModelIndex, int, int)));
    20. model.removeRow(0);
    21. return 0;
    22. }
    To copy to clipboard, switch view to plain text mode 

    Result: void Dummy::check(const QModelIndex&, int, int) 0 0
    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. Mapping Index from View to Model
    By toodles in forum Newbie
    Replies: 1
    Last Post: 3rd July 2012, 19:37
  2. Replies: 1
    Last Post: 6th October 2011, 00:13
  3. Replies: 0
    Last Post: 12th October 2010, 05:22
  4. Replies: 0
    Last Post: 7th October 2010, 19:38
  5. Replies: 0
    Last Post: 10th September 2009, 09:43

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.