Reputation: 459
I have a problem with Qt on Android in all my applications: after I close the QFileDialog (code below), I have a blank black window. I can't do anything in the application except close it.
Here is the code I use:
QFileDialog dialog(this, tr("Open Markdown File"));
dialog.setMimeTypeFilters({"text/markdown"});
dialog.setAcceptMode(QFileDialog::AcceptOpen);
if (dialog.exec() == QDialog::Accepted) {
const QString file = dialog.selectedFiles().at(0);
if (file == path || file.isEmpty()) return;
openFile(file);
}
After some more debugging i figured out, that it reaches the end of the code. I also tried to add Q[Core|Gui]Application::processEvents()
and QMainWindow::repaint()
but i istill have the blank screen as you cas see in the screenshot above.
The Code is in a QMainWindow
and is executed in the main thread. The APP has a QApplication
object. After the end of the code is reached, the main thread aka main event loop runs as usual, but I have a black window.
You can find all the code on GitHub, but only the part I showed causes problems.
Upvotes: 2
Views: 534
Reputation: 676
Works well on my configuration:
Demo: https://youtube.com/shorts/KkyrTYkTNb0?feature=share. Your app open and save file well, FileDialog works well too. So no assumptions about the reasons you see blank screen: may be phone software version, may be some feature of your Qt version.
I did several changes in your project however to be able to read and write files on android:
READ_EXTERNAL_STORAGE
and WRITE_EXTERNAL_STORAGE
permissions to manifest.
setDirectWriteFallback(true)
to mainwindow.cpp
:1139: QSaveFile f(path, this);
1140: f.setDirectWriteFallback(true); //!!!
1141: if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
...
otherwise file created, but I had an error on f.commit()
:
Upvotes: 1