Results 1 to 14 of 14

Thread: Problem with Splash Screen ?

  1. #1
    Join Date
    Mar 2006
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Problem with Splash Screen ?

    Hello,

    Here is my code. I am trying to display the "Logo" image as a splash screen on top all of my windows. But when executing , the splash screen is displayed on bottom of the main widget. What is the reason ? How can I solve it ?

    Qt Code:
    1. #include <qapplication.h>
    2. #include "welform.h"
    3. #include <qtimer.h>
    4. #include <qpixmap.h>
    5. #include <qsplashscreen.h>
    6.  
    7.  
    8. int main( int argc, char ** argv )
    9. {
    10.  
    11.  
    12. QSplashScreen *splash=NULL;
    13. QApplication a( argc, argv );
    14. welForm *w;
    15.  
    16.  
    17. QPixmap logo(QPixmap::fromMimeSource("Logo"));
    18. splash=new QSplashScreen(logo,Qt::WStyle_StaysOnTop|Qt::WX11BypassWM);
    19. splash->show();
    20. QTimer::singleShot(5*1000,splash,SLOT(close()));
    21.  
    22. w=new welForm(0,"welForm");
    23. a.setMainWidget(w);
    24. w->show();
    25.  
    26. //delete splash;
    27. //a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    28. int rc=a.exec();
    29.  
    30. //splash->finish(w); this finish() also not work.... so I commented it.
    31. if(splash)
    32. delete splash;
    33.  
    34. return rc;
    35. }
    To copy to clipboard, switch view to plain text mode 


    thanks in advance............

    A S Vinod
    Last edited by wysota; 7th March 2007 at 11:01. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with Splash Screen ?

    Try this:
    Qt Code:
    1. QApplication app(argc, argv);
    2. QSplashScreen *splashscreen = new QSplashScreen(QPixmap::fromMimeSource("Logo"), Qt::WDestructiveClose|Qt::WStyle_StaysOnTop); // no need for other flags
    3. splashscreen->show();
    4. app.processEvents(); // this should make the splash appear
    5. welForm *w = new welForm(0,"welForm");
    6. app.setMainWidget(w);
    7. w->show();
    8. QTimer::singleShot(5000,splashscreen,SLOT(close())); // timer needs the event queue
    9. return app.exec();
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2006
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Problem with Splash Screen ?

    Hello,

    I had tried your code. But the result was same. The splash screen always appeared below to the main window.


    So what will be he exact problem....


    Vinod

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with Splash Screen ?

    Did you pass any window flags to the main window?

  5. #5
    Join Date
    Mar 2006
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Problem with Splash Screen ?

    No , I didn't pass any arguments to main window...

    But , now I solve the problem.

    By just calling the finish(mainWindow) function of SplashScreen class before calling show(mainWindow).

    Here is the working code :-

    Qt Code:
    1. int main( int argc, char ** argv )
    2. {
    3.  
    4. QApplication a( argc, argv );
    5.  
    6.  
    7. QSplashScreen *splash=new
    8. QSplashScreen(QPixmap::fromMimeSource("Logo"),Qt::WDestructiveClose|Qt::WStyle_StaysOnTop);
    9. splash->show();
    10. a.processEvents();
    11. welForm *w=new welForm(0,"welForm");
    12. a.setMainWidget(w);
    13. splash->finish(w);
    14. w->show();
    15.  
    16. QTimer::singleShot(10000,splash,SLOT(close()));
    17. return a.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 



    Thank You...
    Last edited by wysota; 7th March 2007 at 11:00. Reason: missing [code] tags

  6. #6
    Join Date
    Apr 2006
    Posts
    5
    Thanks
    1
    Platforms
    Unix/X11 Windows

    Default Re: Problem with Splash Screen ?

    hello...
    i am trying to display a splash screen before my application starts. But it is not displaying SplashScreen. given below is my code.

    Qt Code:
    1. #include <QApplication>
    2.  
    3. #include "client.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. QPixmap pixmap("redcross.png");
    9. QSplashScreen *splash = new QSplashScreen(pixmap);
    10. splash->show();
    11. app.processEvents();
    12. splash->showMessage("Loaded modules");
    13.  
    14. client client;//inherited from QDialog
    15. splash->finish(&client);
    16. client.show();
    17.  
    18. QTimer::singleShot(5000,splash,SLOT(close())); // timer needs the event queue
    19.  
    20. return app.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 

    thanx
    Last edited by wysota; 7th March 2007 at 10:45. Reason: missing [code] tags

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with Splash Screen ?

    I tested the code and it worked for me. Maybe the problem is that you use a relative path to the redcross.png image? If QSplashScreen can't find it, it won't be displayed.

  8. The following user says thank you to wysota for this useful post:

    yabadabadoo (7th March 2007)

  9. #8
    Join Date
    Apr 2006
    Posts
    5
    Thanks
    1
    Platforms
    Unix/X11 Windows

    Smile Re: Problem with Splash Screen ?

    yes.... that was the problem... thank you very much..

  10. #9
    Join Date
    Jan 2019
    Posts
    3
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Problem with Splash Screen ?

    can i use finish before calling show() on the mainwindow?

  11. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Problem with Splash Screen ?

    Quote Originally Posted by Prashant Kumar View Post
    can i use finish before calling show() on the mainwindow?
    That is what the code in post #6 does, isn't it?.

    Cheers,
    _

  12. #11
    Join Date
    Jul 2015
    Location
    Ahmedabad, India
    Posts
    12
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem with Splash Screen ?

    Hello,

    I am running QSplashscreen over my Qt application. I am setting five different images on each second with numeric data. After running few hours it just shows me a black popup without image. The pixmap loading images and setting on splash but, It shows me black screen for 5 seconds. If you guys have any solution for this issue, kindly help me.

    Thanks

    Tushar

  13. #12
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problem with Splash Screen ?

    Don't hijack old threads for a new post, please.

    My crystal ball is at work, so I can't use it. And without my crystal ball, I can't see the invisible code you have posted to show what you are doing. And since I can't see the invisible code, I can't give you any suggestions for what might be wrong, but I have a pretty good idea. Sorry.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  14. #13
    Join Date
    Jul 2015
    Location
    Ahmedabad, India
    Posts
    12
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem with Splash Screen ?

    #ifndef TIMER_H
    #define TIMER_H

    #include <QTimer>
    #include <QDebug>
    #include <QSplashScreen>
    #include <QPixmap>
    #include <QPainter>

    class timer_s: public QTimer
    {
    Q_OBJECT

    public:
    int timePassed;
    QSplashScreen *splash;
    float temp;
    QFont splashfont;
    QString tem,Con_tem,TClock,Snap_Smiley_Image_Path;
    QByteArray ab,Con_ab;
    QByteArray ba;
    int i1,i2;
    const char* mychar;
    const char* Conv_char;
    float a, b;
    Qt::Alignment align,align2;
    float LowtempC,HightempC;
    float HightempF,LowtempF,DisableRedC;
    QPixmap InitImage;
    QPainter painter;

    explicit timer_s(QObject *parent = 0) : QTimer(parent)
    {
    splash = new QSplashScreen();
    }

    private slots:

    void tick()
    {
    if(timePassed == 8)
    splash->show();
    if(timePassed == 0)
    {
    splash->close();
    splash->deleteLater();
    stop();
    deleteLater();
    }
    else
    {
    InitImage.load(""+Snap_Smiley_Image_Path+QString("/timer-%1.png").arg(timePassed)+"");
    splash->setPixmap(InitImage);
    timePassed--;
    }
    }

    void CelsToF()//F temp to C
    {
    if((TClock == "false" && timePassed == 5) || (TClock == "true" && timePassed == 2))
    {
    splashfont.setFamily("Helvetica Neue Regular");
    splashfont.setPixelSize(110);
    DisableRedC = HightempC;
    i1 = tem.count();
    ab = tem.toLatin1().insert(i1,"°C");
    align = Qt::AlignVCenter|Qt::AlignRight;
    mychar = ab.data();
    Con_tem = QString::number(temp);
    i2 = Con_tem.count();
    Con_ab = Con_tem.toLatin1().insert(i2,"°F");
    align2 = Qt::AlignVCenter|Qt::AlignRight;
    Conv_char = Con_ab.data();//Convert C to F End
    splash->show();
    }
    if(timePassed == 0)
    {
    splash->close();
    splash->deleteLater();
    tem.clear();
    HightempC = 0;
    LowtempC = 0;
    a = 0;
    b = 0;
    stop();
    memset(&Conv_char, 0, sizeof(Conv_char));
    memset(&mychar, 0, sizeof(mychar));
    deleteLater();
    }
    if(tem.toFloat() >= HightempC && DisableRedC != -999 && timePassed != 0)
    {
    if(timePassed == 5 || (TClock == "true" && timePassed == 2)){
    splash->showMessage(tr(mychar),align,Qt::white);
    splash->setFont(splashfont);
    }
    if(TClock == "true" && (timePassed == 2 || timePassed == 1))
    InitImage.load(""+Snap_Smiley_Image_Path+QString("/high%1.png").arg(timePassed)+"");
    else
    InitImage.load(""+Snap_Smiley_Image_Path+QString("/high%1.png").arg(timePassed)+"");
    painter.begin(&InitImage);//Display Other Temp on Top Right Start
    painter.setPen(Qt::white);
    painter.setFont(QFont("Helvetica Neue Regular",22));
    painter.drawText(InitImage.rect(),Qt::AlignTop|Qt: :AlignRight,Conv_char);//Display Other Temp on Top Right end
    painter.end();
    splash->setPixmap(InitImage);
    }
    else if(tem.toFloat() <= LowtempC && DisableRedC != -999 && timePassed != 0)
    {
    InitImage.load(""+Snap_Smiley_Image_Path+QString("/invalid%1.png").arg(timePassed)+"");
    splash->setPixmap(InitImage);
    }
    else
    {
    if(timePassed == 5 || (TClock == "true" && timePassed == 2)){
    splash->showMessage(tr(mychar),align,Qt::white);
    splash->setFont(splashfont);
    }
    if(timePassed != 0)
    {
    if(TClock == "true" && (timePassed == 2 || timePassed == 1))
    InitImage.load(""+Snap_Smiley_Image_Path+QString("/valid%1.png").arg(timePassed)+"");
    else
    InitImage.load(""+Snap_Smiley_Image_Path+QString("/valid%1.png").arg(timePassed)+"");
    painter.begin(&InitImage);//Display Other Temp on Top Right Start
    painter.setPen(Qt::white);
    painter.setFont(QFont("Helvetica Neue Regular",22));
    painter.drawText(InitImage.rect(),Qt::AlignTop|Qt: :AlignRight,Conv_char);//Display Other Temp on Top Right end
    painter.end();
    splash->setPixmap(InitImage);
    }
    }
    timePassed--;
    }

    void validtemp()
    {
    if((TClock == "false" && timePassed == 5) || (TClock == "true" && timePassed == 2))
    {
    splashfont.setFamily("Helvetica Neue Regular");
    splashfont.setPixelSize(110);
    //splashfont.setBold(true);
    //tem = QString::number(temp);
    tem = QString::number(temp,'f',1/*floor(b*10.0)/10.0*/);
    i1 = tem.count();
    ab = tem.toLatin1().insert(i1,"°F");
    align = Qt::AlignVCenter|Qt::AlignRight;
    mychar = ab.data();
    a = temp - 32;
    b = a * 5/9;
    Con_tem = QString::number(b,'f',1/*floor(b*10.0)/10.0*/);
    i2 = Con_tem.count();
    Con_ab = Con_tem.toLatin1().insert(i2,"°C");
    align2 = Qt::AlignRight|Qt::AlignBottom;
    Conv_char = Con_ab.data();
    splash->show();
    }
    if(timePassed == 0)
    {
    //qDebug()<< timePassed;
    splash->close();
    splash->deleteLater();
    HightempF = 0;
    LowtempF = 0;
    temp = 0;
    stop();
    memset(&Conv_char, 0, sizeof(Conv_char));
    memset(&mychar, 0, sizeof(mychar));
    deleteLater();
    }
    if(temp >= HightempF && HightempF != -999 && timePassed != 0)
    {
    if(timePassed == 5 || (TClock == "true" && timePassed == 2)){
    splash->showMessage(tr(mychar),align,Qt::white);
    splash->setFont(splashfont);
    }
    if(TClock == "true" && (timePassed == 2 || timePassed == 1))
    InitImage.load(""+Snap_Smiley_Image_Path+QString("/high%1.png").arg(timePassed)+"");
    else
    InitImage.load(""+Snap_Smiley_Image_Path+QString("/high%1.png").arg(timePassed)+"");
    painter.begin(&InitImage);
    painter.setPen(Qt::white);
    painter.setFont(QFont("Helvetica Neue Regular",22));
    painter.drawText(InitImage.rect(),Qt::AlignTop|Qt: :AlignRight,Conv_char);
    painter.end();
    splash->setPixmap(InitImage);
    }
    else if(temp <= LowtempF && HightempF != -999 && timePassed != 0)
    {
    InitImage.load(""+Snap_Smiley_Image_Path+QString("/invalid%1.png").arg(timePassed)+"");
    splash->setPixmap(InitImage);
    }
    else
    {
    if(timePassed == 5 || (TClock == "true" && timePassed == 2)){
    splash->showMessage(tr(mychar),align,Qt::white);
    splash->setFont(splashfont);
    }
    if(timePassed != 0)
    {
    if(TClock == "true" && (timePassed == 2 || timePassed == 1))
    InitImage.load(""+Snap_Smiley_Image_Path+QString("/valid%1.png").arg(timePassed)+"");
    else
    InitImage.load(""+Snap_Smiley_Image_Path+QString("/valid%1.png").arg(timePassed)+"");
    painter.begin(&InitImage);
    painter.setPen(Qt::white);
    painter.setFont(QFont("Helvetica Neue Regular",22));
    painter.drawText(InitImage.rect(),Qt::AlignTop|Qt: :AlignRight,Conv_char);
    painter.end();
    splash->setPixmap(InitImage);
    }
    }
    timePassed--;
    }
    };

    #endif // TIMER_H


    This is my code kindly check it and let me know if anything wrong in it.

    Thanks

  15. #14
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problem with Splash Screen ?

    Sorry, no. Your code is unreadable. However, from just glancing at it, it appears you do not understand at all how a QTimer should be used but it is impossible to read unformatted code.

    Post a new thread, and put your code formatted with proper indentation inside of CODE tags (as explained in my signature below) and then I will take a look after I can read it.

    I won't respond to any more messages posted in this thread.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Splash screen showing for two seconds
    By Koas in forum Qt Programming
    Replies: 5
    Last Post: 17th October 2008, 20:40
  2. Using QGraphicsView as a Splash Screen (repaint issues)
    By chezifresh in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2008, 22:22
  3. QTimer based Splash Screen
    By bpetty in forum Newbie
    Replies: 6
    Last Post: 15th December 2006, 01:51
  4. Replies: 3
    Last Post: 8th December 2006, 19:51
  5. Problem with screen update...
    By mysearch05 in forum Qt Programming
    Replies: 2
    Last Post: 27th January 2006, 19:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.