naughtykid
19th October 2011, 02:22
The Open() function will be initiate a number of times based on user's preference.
I learned that QSignalMapper will be clear by it's parent upon the destruction of application.
But what would happened in this case?
Below are the code snippet:
void class1::Open()
{
// opened a folder & and extract a list of directories ...
QSignalMapper *signalMapper = new QSignalMapper(this);
for(int i = 0; i < directoryList.size(); i++)
{
std::cout << directoryList[i].toStdString() << std::endl;
DirWidget *dirWidgetPtr = new DirWidget(directoryList[i]);
signalMapper->setMapping(dirWidgetPtr->_buttonPtr, directoryList[i]);
connect(dirWidgetPtr->_buttonPtr, SIGNAL(clicked()), signalMapper, SLOT(map()));
_flowLayoutPtr->addWidget(dirWidgetPtr);
}
connect(signalMapper, SIGNAL(mapped(QString)), this, SLOT(GetDir(QString)));
}
I learned that QSignalMapper will be clear by it's parent upon the destruction of application.
But what would happened in this case?
Below are the code snippet:
void class1::Open()
{
// opened a folder & and extract a list of directories ...
QSignalMapper *signalMapper = new QSignalMapper(this);
for(int i = 0; i < directoryList.size(); i++)
{
std::cout << directoryList[i].toStdString() << std::endl;
DirWidget *dirWidgetPtr = new DirWidget(directoryList[i]);
signalMapper->setMapping(dirWidgetPtr->_buttonPtr, directoryList[i]);
connect(dirWidgetPtr->_buttonPtr, SIGNAL(clicked()), signalMapper, SLOT(map()));
_flowLayoutPtr->addWidget(dirWidgetPtr);
}
connect(signalMapper, SIGNAL(mapped(QString)), this, SLOT(GetDir(QString)));
}