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.



  • Tnx for reply but I have an error: 'class Splash' has no member named 'setWindowAttributes'

    I have to import somthing?



  • Oh, it's
    @showSplash->setAttribute(Qt::WA_DeleteOnClose, true);@



  • I have just make but..... error: 'class Splash' has no member named 'setWindowAttributes'

    :S no change



  • Don't use setWindowAttributes, use setAttribute as I stated in my previous post.



  • ok now build but not show the screen... :(

    1. but I have read something about GUI Thread, you know something about this?

    2. I try to do the same metod to show Root?



  • [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.



  • but the method to show the view is currect?

    You have sample that I can See?



  • 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



  • I don't know the contents of your showFullScreen() function, so I don't have any further suggestions.



  • some sample?



  • Use the debugger and look when your classes are constructed, methods called and destroyed.



  • Volker I see when the constructor al call but if I put

    @qDebug() << "Destruct"<<endl;@

    in the ~Splash() distructor it was not show in the Application Output. then in theory it was not destroied?



  • 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?



  • where I have to put your code? and what a have to write inside the processEvents(); metod?

    then I control Qsplash



  • The sample is in QSplashScreen's documentation... have a look over there.

    You are not required to write a processEvents() method, but to use the provided one...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.