Results 1 to 2 of 2

Thread: Signal & Slot

  1. #1
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Signal & Slot

    Hello friends,

    i´am nearly ready with my treeview. To expand the child i must double click on the parent.
    But i want expand it by one click so i implement this
    Qt Code:
    1. privat slots:
    2. void expand(const QModelIndex & index);
    To copy to clipboard, switch view to plain text mode 

    in my mainwindow i add this code:
    Qt Code:
    1. connect(qtv, SIGNAL(clicked( const QModelIndex & index )),
    2. this, SLOT(expand(const QModelIndex & index)));
    To copy to clipboard, switch view to plain text mode 

    and after all the implementation:

    Qt Code:
    1. void MainWindow::expand(const QModelIndex & index)
    2. {
    3. if ( index.isValid())
    4. {
    5. qtv->expand(index);
    6. }
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 

    But nothing happens. I must always doubleclick the parent item to expand the child.

    Have anybody an idea what i make wrong??
    Attached Images Attached Images

  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: Signal & Slot

    Don't pass variable names to connect statements. Should be:
    Qt Code:
    1. connect(qtv, SIGNAL(clicked( const QModelIndex & )), this, SLOT(expand(const QModelIndex &)));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. signal and slot across threads having event loop
    By travis in forum Qt Programming
    Replies: 6
    Last Post: 5th November 2007, 23:56
  2. Replies: 2
    Last Post: 16th August 2007, 00:20
  3. signal not getting communicated to slot
    By quickNitin in forum Qt Programming
    Replies: 17
    Last Post: 2nd June 2006, 04:56
  4. Manually send signal to slot
    By donmorr in forum Qt Programming
    Replies: 1
    Last Post: 29th May 2006, 15:03
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18:52

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.