Multiple calls which create multiple instances of QSignalMapper
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:
Code:
void class1::Open()
{
// opened a folder & and extract a list of directories ...
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)));
}
Re: Multiple calls which create multiple instances of QSignalMapper
Quote:
But what would happened in this case?
What would happen to what? The QSignalMapper(s) you create will be destroyed when their parent instance of class1 is destroyed. The DirWidgets will be destroyed when their _flowLayout is destroyed (assuming it is a well behaved QLayout derivative).
Re: Multiple calls which create multiple instances of QSignalMapper
Thanks for the reply ChrisW67.
To be specific:
So is that means class1 keeps all the created QSignalMapper instances until it destroyed?
Or it destroy the previous one right after I initiate a new QSignalMapper?