Show UI Design not in main metod is possible?
-
Hi all of us, i'm a new in the symbian world, I have a problem:
I try to show the UI design view from not main method but not work:
@int main(int argc, char *argv[])
{
QApplication app(argc, argv);MainWindow mainWindow; mainWindow.setOrientation(MainWindow::ScreenOrientationLockPortrait); mainWindow.showExpanded(); RootViewer rootView; rootView.showFullScreen(); return app.exec();
}
@I call the RootView Costructor that is an Qt Design C++ class and have RootViewer.h , RootViewer.cpp, RootViewer.ui
in the RootViewer.ui file I have put only a label with the text line "Root" and the main show currectly in the emulator the screen with the line "Root"
and this is the problem:
this is my RootViewer.cpp :
@
#include "rootviewer.h"
#include "ui_rootviewer.h"
#include "splash.h"
#include <QDebug>
#include <QtGui/QApplication>RootViewer::RootViewer(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::RootViewer)
{
ui->setupUi(this);
lanciaSplash();
}RootViewer::~RootViewer()
{
delete ui;
}void RootViewer::lanciaSplash(){
qDebug()<<"SPLASH"<<endl; Splash showSplash; showSplash.showFullScreen();
}
@why the splash.ui doesn't show ? the qDebug "SPLASH" are written in the Application Output then the method is call...
Someone can help me?
Sorry for my very bad english
-
[quote author="Vetryaspa" date="1307640421"]@void RootViewer::lanciaSplash(){
qDebug()<<"SPLASH"<<endl; Splash showSplash; showSplash.showFullScreen();
}@
[/quote]The showFullScreen() function is probably non-blocking. The splash screen will be destroyed immediately after you showed it, because it is created on the stack. This means the screen will not be showed at all. A better solution would most likely be:
@
void RootViewer::lanciaSplash(){qDebug()<<"SPLASH"<<endl; Splash *showSplash = new Splash; showSplash->setWindowAttributes(WA_DeleteOnClose, true); // delete the thing when we're done showing showSplash->showFullScreen();
}@
The widget is created on the heap and it stays in existence until it is explicitly deleted.
-
[quote author="Vetryaspa" date="1307691735"]1. but I have read something about GUI Thread, you know something about this?[/quote]I know something about the GUI thread, but I don't know enough about your code to see where this question becomes relevant.
[quote]2. I try to do the same metod to show Root?[/quote]Not necessary, since rootView stays in scope during the run of the application.
-
An idea: you have said that the splash are quickly destroyed, tha exist a metod where i can intercept the event of closing of the splash?
so I can control if it will be created or not....
whit destructor method [ ~Splash() ] I can see this[Edit:] I have try and the destructor will not call
-
If you use the pointer, then it's only destroyed when you call delete on it.
Problem could be caused by the not yet running event loop. You might want to try
@
app.processEvents();
// or
qApp->processEvents();
@to work around this.
Did you try "QSplashScreen":http://doc.qt.nokia.com/4.7/qsplashscreen.html?