PDA

View Full Version : QTreeWidget signal not working



Kapil
28th April 2006, 09:15
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...



QList<QTreeWidgetItem *> widgetList = m_uiMainWindow.routingFlowTree->findItems (QString("Add Design"),Qt::MatchRecursive);
if(widgetList.size() != 0)
{
QTreeWidgetItem *pAddDesignItem = widgetList.takeFirst();
QObject::connect(m_uiMainWindow.routingFlowTree, SIGNAL(itemDoubleClicked(*pAddDesignItem , 0)), this, SLOT(onDoubleClickAddDesignItem()));

}


Thanking you,

with regards,
Kapil

jpn
28th April 2006, 09:41
You may NOT add parameter names or values in SIGNAL and SLOT macros.


SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int))

Kapil
28th April 2006, 09:55
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

zlatko
28th April 2006, 09:58
Use connect for conecting needed item with needed slot

Kapil
28th April 2006, 10:03
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...

jpn
28th April 2006, 10:08
// connection
connect(m_uiMainWindow.routingFlowTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(onDoubleClickAddDesignItem(QTreeWidgetItem*, int)));

// slot
void Something::onDoubleClickAddDesignItem(QTreeWidgetI tem* item, int column)
{
QList<QTreeWidgetItem *> widgetList = m_uiMainWindow.routingFlowTree->findItems(QString("Add Design"),Qt::MatchRecursive);

if (widgetList.size() > 0 && item == widgetList.takeFirst())
{
// do your thing
}
}

Kapil
28th April 2006, 10:19
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