Re: How to go about saving?
You have manually created 108 spinboxes and date edits?
You would have been much better off to declare them in a QList in the first place. Then you can easily iterate through them.
Code:
{
public:
MainWindow() {
for (int i = 0;i < 108;++i)
{
payments_sb.append(sb);
gl.addWidget(de,i,0);
dueDates_de.append(de);
gl.addWidget(de,i,1);
}
w.setLayout(gl);
setCentralWidget(w);
}
void writeToStream(QDataStream& ds)
{
ds << payments_sb.length();
for (int i=0;i<payments_sb.length();++i)
{
ds << payments_sb.at(i).value() << dueDates_de.at(i) ... ;
}
}
private:
QList<QSpinBox* > payments_sb;
QList<QDateEdit* > dueDates_de;
}
..
Or use a QTableWidget or View with custom delegates for your datatypes.
Joh
Re: How to go about saving?
Yes, I manually created them using QT Designer. They all go dateEdit_1, dateEdit_2, etc. Is there a way to cycle through them? If not, looks like some crying is in order as I will either have to do it manually, or just rework the program using QList (or some other solution).
(fuck it, I may just write a for statement that will output the needed code to a text document and then copy that into the source...)
Re: How to go about saving?
Ok if you insist you can loop through the children of your mainwidget! But thats not really good design! But definitely better than hard coding!
Code:
int i = 1;
do
{
de
= parentWidget
->findChild<QDateEdit
*>
(QString("dateEdit_%1").
arg(i
));
if (de) {
...
}
++i;
} while (de);
Joh