Results 1 to 2 of 2

Thread: currentChanged protected slot - cant get working

  1. #1
    Join Date
    May 2006
    Posts
    28
    Thanks
    8
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default currentChanged protected slot - cant get working

    Hi,

    I've been playing with Qt 4.1.1 now for a few weeks, getting my app done.
    Still a newbie however as i have a simple problem.

    currentChanged protected slot on a treeView, I cant seem to get working
    I have a treeView with some rows. I got clicked() working, but I really need a currentChanged to work when the row selected is changed.

    here's some code below:

    Qt Code:
    1. public:
    2. QTreeView *treeView;
    3. protected slots:
    4. virtual void currentChanged (const QModelIndex & current, const QModelIndex & previous);
    5.  
    6. void GamesTab::currentChanged (const QModelIndex & current, const QModelIndex & previous)
    7. {
    8. doGameInfo();
    9. }
    To copy to clipboard, switch view to plain text mode 

    What am I missing anyone ?

  2. #2
    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: currentChanged protected slot - cant get working

    You should use signals and slots:

    Qt Code:
    1. QItemSelectionModel *selmod = tv->selectionModel();
    2. connect(selmod, SIGNAL( currentChanged ( const QModelIndex &, const QModelIndex &)),
    3. this, SLOT(onCurrentChanged(const QModelIndex &)));
    4. //...
    5.  
    6. void someClass::onCurrentChanged(const QModelIndex &current){
    7. doGameInfo();
    8. }
    To copy to clipboard, switch view to plain text mode 

  3. The following 2 users say thank you to wysota for this useful post:

    Big Duck (12th June 2006), klaus1111 (20th July 2006)

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.