Results 1 to 7 of 7

Thread: Reimplement currentChanged and selectionChanged problems ??

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Reimplement currentChanged and selectionChanged problems ??

    I want to know when the user change the current cell, and when the selection change So I use currentChanged and selectionchanged reimplemented for my custom tableview.

    Ok, I dont know what is the problem but If I do click on a cell I need to wait almost a second to view the current cell selected......
    (And I have comment the possible code asociated to each slot)

    Any Idea ?

  2. #2
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Reimplement currentChanged and selectionChanged problems ??

    Quote Originally Posted by tonnot View Post
    Any Idea ?
    If you were to provide us with some code, it would probably help us to help you... Have you checked the original implementation of those methods to make sure that you are not missing something that is critical? Also, if you might not want to call QTableView::currentChanged, you might still want to call QAbstractItemView::currentChanged...?

  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Reimplement currentChanged and selectionChanged problems ??

    I only have this code (without any other commands inside them :
    Qt Code:
    1. void A_table::currentChanged ( const QModelIndex & current, const QModelIndex & previous ) {}
    2. void A_table::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected){}
    To copy to clipboard, switch view to plain text mode 

    And as public slots :
    Qt Code:
    1. public slots:
    2. void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
    3. void currentChanged ( const QModelIndex & current, const QModelIndex & previous );
    To copy to clipboard, switch view to plain text mode 

    A_table is a custom widget extending QTableView and it is connected to a custom model extending QAbstractTableModel(parent)
    All works fine except this issue.
    Thanks

  4. #4
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Reimplement currentChanged and selectionChanged problems ??

    I have never 'converted' a protected virtual function into a public slot, so I have no idea whether it can/should work, but what is certain is that you are not calling any of the parent's implementation of those methods and that might be the cause of your problem. Have you tried to put a trace in your version of those methods, just to make sure that they are actually being executed?

  5. #5
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Reimplement currentChanged and selectionChanged problems ??

    But they are slots. So If I use a Qwidget extendig a QTableView I have to declare as public slots , ins't ?

    And this are the only properties I set :

    Qt Code:
    1. this->setSortingEnabled(false);
    2. this->setSelectionBehavior(QAbstractItemView::SelectItems);
    3. this->setSelectionMode( QAbstractItemView::SingleSelection);
    4. this->horizontalHeader()->setStretchLastSection(true);
    5. this->setEditTriggers(QAbstractItemView::NoEditTriggers);
    To copy to clipboard, switch view to plain text mode 

    By now, I have to comment selectionchanged.
    Another strange behavior is that every cell I click remains selected,.

    Keep needing help on this.

  6. #6
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Reimplement currentChanged and selectionChanged problems ??

    Quote Originally Posted by tonnot View Post
    Keep needing help on this.
    No, what you need is to do your homework and read Qt's documentation (more carefully, if you have already read it).

  7. The following user says thank you to agarny for this useful post:

    tonnot (20th April 2011)

  8. #7
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Reimplement currentChanged and selectionChanged problems ??

    From help : (model view tutorial)
    Views manage selections within a separate selection model, which can be retrieved with the selectionModel() method. We retrieve the selection Model in order to connect a slot to its selectionChanged() signal.
    So, I have now something likethis:
    Qt Code:
    1. QItemSelectionModel *selectionModel= Table>selectionModel();
    2. connect(selectionModel, SIGNAL(selectionChanged (const QItemSelection &, const QItemSelection &)),
    3. this, SLOT(selectionChangedSlot(const QItemSelection &, const QItemSelection &)));
    To copy to clipboard, switch view to plain text mode 

    Ok, now it works (not very well but I have not the last problems)

    And, I can to reimplement the currentChanged slot or is it forbidden ?

    PS: I pray everyday in order QT people include more information into QT Reference

Similar Threads

  1. QTabWidget currentChanged signal
    By vkincaid in forum Qt Programming
    Replies: 4
    Last Post: 9th December 2009, 18:07
  2. Problem connecting selectionChanged
    By jano_alex_es in forum Newbie
    Replies: 2
    Last Post: 1st June 2009, 15:57
  3. ListView and CurrentChanged
    By kroenecker in forum Newbie
    Replies: 13
    Last Post: 24th March 2007, 02:35
  4. no such signal QListBox::currentChanged()
    By jopie bakker in forum Newbie
    Replies: 2
    Last Post: 2nd March 2006, 15:17
  5. QTabWidget SIGNAL currentChanged()
    By campana in forum Qt Programming
    Replies: 3
    Last Post: 28th February 2006, 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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.