In *.h file:
struct StructCheckedEntries
{
StructCheckedEntries():
filename(""),
checkbox(0),
combobox(0),
lineedit(0)
{
}
inline void Free()
{
if (checkbox)
{
delete checkbox;
checkbox = 0;
}
if (combobox)
{
delete combobox;
combobox = 0;
}
if (lineedit)
{
delete lineedit;
lineedit = 0;
}
}
};
QHash<QString,StructCheckedEntries *> HCheckedEntries;
struct StructCheckedEntries
{
StructCheckedEntries():
filename(""),
checkbox(0),
combobox(0),
lineedit(0)
{
checkbox = new QCheckBox;
combobox = new QComboBox;
lineedit = new QLineEdit;
}
inline void Free()
{
if (checkbox)
{
delete checkbox;
checkbox = 0;
}
if (combobox)
{
delete combobox;
combobox = 0;
}
if (lineedit)
{
delete lineedit;
lineedit = 0;
}
}
QString filename;
QCheckBox *checkbox;
QComboBox *combobox;
QLineEdit *lineedit;
};
QHash<QString,StructCheckedEntries *> HCheckedEntries;
To copy to clipboard, switch view to plain text mode
In *.cpp file:
StructCheckedEntries entr;
entr.filename = "fileName";
entr.checkbox->setText("checkbox");
entr.combobox->addItem("combobox");
entr.lineedit->setText("lineedit");
HCheckedEntries.insert( "123", &entr );
StructCheckedEntries *pentr = HCheckedEntries.value("123");
qDebug() << "FileName: " << pentr->filename;
qDebug() << "ComboBox: " << pentr->combobox->itemText(0);
qDebug() << "LineEdit: " << pentr->lineedit->text();
if (pentr->checkbox->checkState() & Qt::Checked)
qDebug() << "Checked";
else
qDebug() << "Unchecked";
StructCheckedEntries entr;
entr.filename = "fileName";
entr.checkbox->setText("checkbox");
entr.combobox->addItem("combobox");
entr.lineedit->setText("lineedit");
HCheckedEntries.insert( "123", &entr );
StructCheckedEntries *pentr = HCheckedEntries.value("123");
qDebug() << "FileName: " << pentr->filename;
qDebug() << "ComboBox: " << pentr->combobox->itemText(0);
qDebug() << "LineEdit: " << pentr->lineedit->text();
if (pentr->checkbox->checkState() & Qt::Checked)
qDebug() << "Checked";
else
qDebug() << "Unchecked";
To copy to clipboard, switch view to plain text mode
To delete use pentr->Free();
Bookmarks