In my application, I have a list view. Selecting another element in it raises an event:
connect(listView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(item_changed(const QModelIndex &, const QModelIndex &)));
void MainWindow::item_changed(const QModelIndex & current, const QModelIndex & previous)
{
qDebug() << "\n" << "item_changed(), caller: " << sender()->objectName();
if (current.isValid())
{
change_query(tokens.join("+"));
}
}
This calls another slot - change_query ().
void MainWindow::change_query(QString newquery)
{
qDebug() << "change_query(), caller: " << sender()->objectName();
QUrl query (newquery);
frame->load(query);
connect(frame, SIGNAL(loadFinished(bool)), this, SLOT(loading_finished()));
}
And finally, when the page is fully loaded, it should call load_finished ()
void MainWindow::loading_finished()
{
qDebug() << "loading_finished(), caller: " << sender()->objectName();
}
But, to my surprise, the conclusion:
item_changed(), caller: "SelectionModel"
change_query(), caller: "SelectionModel"
loading_finished(), caller: "frame"
item_changed(), caller: "SelectionModel"
change_query(), caller: "SelectionModel"
loading_finished(), caller: "frame"
loading_finished(), caller: "frame"
item_changed(), caller: "SelectionModel"
change_query(), caller: "SelectionModel"
loading_finished(), caller: "frame"
loading_finished(), caller: "frame"
loading_finished(), caller: "frame"
item_changed(), caller: "SelectionModel"
change_query(), caller: "SelectionModel"
loading_finished(), caller: "frame"
loading_finished(), caller: "frame"
loading_finished(), caller: "frame"
loading_finished(), caller: "frame"
As you can see, every time I change my choice, another instance (?) Of WebFrame is created and loaded, or the page is loaded +1 times each cycle. I spent the last 2 hours figuring out where the problem is and I donβt see anything.