Solved Widget QSplashScreen still not working in Android
-
int main(int argc, char *argv[]) { QApplication a(argc, argv); QPixmap splashpic("qrc:/splash.png"); //QSplashScreen splash(splashpic.scaledToWidth(QApplication::desktop()->availableGeometry().width())); QSplashScreen splash(splashpic); splash.show(); a.processEvents(); QTextCodec* codec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForLocale(codec); MainWindow w(Q_NULLPTR); w.show(); splash.finish(&w); return a.exec(); }
White screen before main window appears. Qt 5.12, Android 7.1.
-
@Gourmet QSplashscreen is not the class to go on android, it‘s made more for Desktop apps.
You have to go native on this with a drawable
see this link, it should help greatly
-
@J-Hilk said in Widget QSplashScreen still not working in Android:
QSplashscreen is not the class to go on android, it‘s made more for Desktop apps.
Isn't Qt a multiplatform framework? What is the major difference between splash on desktop and mobile? Why QSplashScreen cannot work on mobile as other widgets work?
-
@Gourmet said in Widget QSplashScreen still not working in Android:
Why QSplashScreen cannot work on mobile as other widgets work
QSplashScreen works exactly as other widgets work. Thats the problem.
The Splashscreen, the white one in your case, is provided by the OS (android in this case) during startup of your applications. Once Android handles the paint operation to your application you see your QSplashscreen
-
@J-Hilk I think this is a bug. Strange but I did not find any report about this. Therefore I created new one. It is already marked as P2 Important... https://bugreports.qt.io/browse/QTBUG-85253
-
I temporary solved this with simple actions:
- Created 3 static splash screen pictures in resolutions 800x480, 1280x800, 1920x1150 with same name splash.png and placed them to folders android/res/drawable-ldpi, android/res/drawable-mdpi, android/res/drawable-hdpi respectively.
- Uncommeted in AndroidManifest.xml line:
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splash"/>
Then built the application. First white screen with app name appears for short time about 1 second. Then my image appears for all other time needed for application initialization. This is not best solution cause it does not allow show init process dynamically in splash. But it is much better than just white screen.
-
If you want something more fancy, there are links provided in the bug reports to help you do that.