Results 1 to 7 of 7

Thread: QTreeWidget signal not working

  1. #1
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTreeWidget signal not working

    Hi...

    There is a small problem in it.. whenever i double click on any of my QTreeWIdgetItem, it does not do anything.. infact does not respond to it..
    HAve followed all the conventions...
    like declaring func in slots and calling the Q_OBJECT...
    also i tried to put the arguments as that of signals and slots as same but still it did not work..
    i am posting the few lines of code whcih are not wrkin... plz tell what can be the fault in it.. it even does not show me any errors while compiling.. its just that it doesnt work...

    Qt Code:
    1. QList<QTreeWidgetItem *> widgetList = m_uiMainWindow.routingFlowTree->findItems (QString("Add Design"),Qt::MatchRecursive);
    2. if(widgetList.size() != 0)
    3. {
    4. QTreeWidgetItem *pAddDesignItem = widgetList.takeFirst();
    5. QObject::connect(m_uiMainWindow.routingFlowTree, SIGNAL(itemDoubleClicked(*pAddDesignItem , 0)), this, SLOT(onDoubleClickAddDesignItem()));
    6.  
    7. }
    To copy to clipboard, switch view to plain text mode 

    Thanking you,

    with regards,
    Kapil
    All you have to decide is what to do with the time that is given to you

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTreeWidget signal not working

    You may NOT add parameter names or values in SIGNAL and SLOT macros.
    SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int))
    J-P Nurmi

  3. #3
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidget signal not working

    Hi...

    Thanks for the reply,

    i want the signal to be emitted when a particular sub item of the QTreeWidget is double clicked.. if i do not add the parameter names then it executes the same slot for any of the items clicked on the Tree Widget .. i want different slots to be executed for different tree widget items clicked...

    what do i do for that....
    what i tried didnt work...

    with regards ,
    Kapil
    All you have to decide is what to do with the time that is given to you

  4. #4
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget signal not working

    Use connect for conecting needed item with needed slot
    a life without programming is like an empty bottle

  5. #5
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidget signal not working

    Quote Originally Posted by zlatko
    Use connect for conecting needed item with needed slot
    Hi..

    am doing that only.. just check on the small code which i have put.. this would give u some idea...
    All you have to decide is what to do with the time that is given to you

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTreeWidget signal not working

    Qt Code:
    1. // connection
    2. connect(m_uiMainWindow.routingFlowTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(onDoubleClickAddDesignItem(QTreeWidgetItem*, int)));
    3.  
    4. // slot
    5. void Something::onDoubleClickAddDesignItem(QTreeWidgetItem* item, int column)
    6. {
    7. QList<QTreeWidgetItem *> widgetList = m_uiMainWindow.routingFlowTree->findItems(QString("Add Design"),Qt::MatchRecursive);
    8.  
    9. if (widgetList.size() > 0 && item == widgetList.takeFirst())
    10. {
    11. // do your thing
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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

    Kapil (28th April 2006)

  8. #7
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidget signal not working

    Hi..

    Thanks a lot for the code block.. It solves the problem... I was trying to put on this idea that ur answer came..

    Thanks again...

    with regards..
    Kapil
    All you have to decide is what to do with the time that is given to you

Similar Threads

  1. QTreeWidget clicked signal
    By ^NyAw^ in forum Qt Programming
    Replies: 41
    Last Post: 30th January 2010, 11:42
  2. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  3. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  4. QTreeWidget double click signal
    By Pinco Pallino in forum Newbie
    Replies: 2
    Last Post: 18th November 2006, 16:37
  5. QTreeWidget SIGNAL
    By raphaelf in forum Newbie
    Replies: 6
    Last Post: 5th March 2006, 17:35

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.