Hi,
I have a problem that is driving me crazy.
I am working on an animation software. I made a suggestion for a Xsheet feature, that would show you the present drawings in your project. In the QDialog there was a Papagayo button, and if you pressed the button, you could choose a papagayo file, and have the contents loaded to the QStringList mPapaLines, from where it is written to the Xsheet (a QTableWidget). It worked flawlessly.
There are two functions loadPapa() and writePapa(). loadPapa() is called when you open the file, and read its content into a QStringList. writePapa() is called after loadPapa(), and everytime there are changes in the Xsheet.
Now I have (upon request) made the xsheet dockable, It is the same code and it still works, but the filedialog appears twice?! I have to pick the file twice? After I have picked it the first time, it loads the data into the xsheet, so it calls AND executes the writePapa function, before it reopens the fileDialog. Why? The function loadPapa is 100% the same code as before I made it dockable.
void Xsheet::loadPapa()
{
mPapaLines->clear();
tr("Open *.pgo file"), "", tr("Pgo Files (*.pgo)"));
return;
while (!in.atEnd()) {
tmp.remove("\t");
mPapaLines->append(tmp);
}
file.close();
writePapa();
}
void Xsheet::loadPapa()
{
mPapaLines->clear();
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open *.pgo file"), "", tr("Pgo Files (*.pgo)"));
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QTextStream in(&file);
while (!in.atEnd()) {
QString tmp = in.readLine();
tmp.remove("\t");
mPapaLines->append(tmp);
}
file.close();
writePapa();
}
To copy to clipboard, switch view to plain text mode
I have debugged it and I have set breakpoints. The result is the same.
- It loads the papagayo file and closes the file.
- It calls the writePapa(), and writes in the xsheet
- it goes back to the ‘}’ after the writePapa() call
- It jumps up to QTextStream in(&file);
- It jumps up to QFile file(fileName)
- it jumps back to the dialog, and opens the dialog…
- If I press Cancel the second time, it returns on the if (!file.open…, and the mPapaLines is empty, which means that the column will be erased at the next updateUi.
If I do a grep for loadPapa, it shows three results:
app/src/xsheet.cpp:48: connect(ui->btnPapa, SIGNAL(clicked(bool)), this, SLOT(loadPapa()));
app/src/xsheet.cpp:130:void Xsheet::loadPapa()
app/src/xsheet.h:37: void loadPapa();
There are no connections made in the xsheet.ui, and I am out of ideas.
Can anyone explain what is happening?
Bookmarks