I am probably overlooking something simple, but do not understand why this function runs without being called. At the end of the constructor I have:
AvailableDialog
::AvailableDialog(BomTableModel
*model,
QWidget *parent
) : ui(new Ui::AvailableDialog)
{
// ...
// for(int i = 1; i < maxProjects + 1; i++)
// ui->quantityCombo->addItem(QString::number(i));
qDebug() << "fillTable being called";
fillTable();
qDebug() << "fillTable finished";
}
AvailableDialog::AvailableDialog(BomTableModel *model, QWidget *parent) :
QDialog(parent),
ui(new Ui::AvailableDialog)
{
// ...
// for(int i = 1; i < maxProjects + 1; i++)
// ui->quantityCombo->addItem(QString::number(i));
qDebug() << "fillTable being called";
fillTable();
qDebug() << "fillTable finished";
}
To copy to clipboard, switch view to plain text mode
With the loop commented out, it works as expected. The loop just fills a combo box with numbers (1 - 10). My debug output is:
fillTable being called
fillTable starting
0
1
2
3
4
5
6
7
8
fillTable ending
fillTable finished
The lines, other than the first and last are inside the function. If I uncomment the loop, the output is:
fillTable starting
0
...
8
fillTable ending
fillTable being called
fillTable starting
0
...
8
fillTable ending
fillTable finished
I originally had the loop after the function call, and noticed that it jumped right back to the function after completing the loop, when I was stepping through it. In that case the output was:
fillTable being called
fillTable starting
0
...
8
fillTable ending
fillTable finished
fillTable starting
0
...
8
fillTable ending
As you can see, for some reason, the code appears to jump inside the function, after the loop ends. I cannot think of any reason for this behavior.
Bookmarks