Results 1 to 14 of 14

Thread: Problem with Splash Screen ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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 09:45. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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.

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

    yabadabadoo (7th March 2007)

  4. #3
    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..

  5. #4
    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?

  6. #5
    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,
    _

  7. #6
    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

  8. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,233
    Thanks
    303
    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.

  9. #8
    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

  10. #9
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,233
    Thanks
    303
    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, 19:40
  2. Using QGraphicsView as a Splash Screen (repaint issues)
    By chezifresh in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2008, 21:22
  3. QTimer based Splash Screen
    By bpetty in forum Newbie
    Replies: 6
    Last Post: 15th December 2006, 00:51
  4. Replies: 3
    Last Post: 8th December 2006, 18:51
  5. Problem with screen update...
    By mysearch05 in forum Qt Programming
    Replies: 2
    Last Post: 27th January 2006, 18: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.