Page 1 of 2 12 LastLast
Results 1 to 20 of 27

Thread: SplashScreen isn't displayed

  1. #1
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default SplashScreen isn't displayed

    Hi. I've got a problem. I've created splashscreen, timer to it, but have a problem. Splashscreen is not displayed when application starts. Here's the code from main.cpp:
    Qt Code:
    1. #include <QApplication>
    2. #include <QPlastiqueStyle>
    3. #include <QSplashScreen>
    4. #include <QTimer>
    5. #include "maker.h"
    6. #include "about.h"
    7.  
    8. int main(int argc, char *argv[])
    9. {
    10. QApplication::setStyle ( new QPlastiqueStyle() );
    11. QApplication app(argc, argv);
    12. QPixmap pixmap(":new/prefix1/poker.png");
    13. QSplashScreen splash(pixmap);
    14.  
    15.  
    16. QTimer splashTimer;
    17.  
    18. splashTimer.setSingleShot( true );
    19.  
    20. splashTimer.setInterval( 4000 ); //4 seconds
    21.  
    22. QObject::connect( &splashTimer, SIGNAL( timeOut() ), &splash, SLOT( close()) );
    23. splashTimer.start();
    24. splash.show();
    25.  
    26. MainWindow MainWindow;
    27. MainWindow.show();
    28.  
    29. return app.exec();
    30. }
    To copy to clipboard, switch view to plain text mode 
    Of course I have this image in my resource file. What's wrong? Regards

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: SplashScreen isn't displayed

    Are you sure it doesn't show up? Something similar seems to show up for me. What if you make it on top:
    Qt Code:
    1. QSplashScreen splash(pixmap, Qt::WindowStaysOnTopHint);
    To copy to clipboard, switch view to plain text mode 

    Btw, there is a more convenient way for setting up a single shot timer:
    Qt Code:
    1. QTimer::singleShot(4000, &splash, SLOT(close()));
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SplashScreen isn't displayed

    Yes, I'm sure. I tried your code - without effect

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: SplashScreen isn't displayed

    In that case the problem must lie within the pixmap. Assure that the pixmap is not null, eg. QPixmap::isNull() returns false.
    J-P Nurmi

  5. #5
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SplashScreen isn't displayed

    In docs I have short definition. How to use
    bool QPixmap::isNull () const
    Regards

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: SplashScreen isn't displayed

    Quote Originally Posted by Salazaar View Post
    In docs I have short definition. How to use
    bool QPixmap::isNull () const
    It's a member function of QPixmap. Call it the same way than you call QWidget::show() or QCoreApplication::exec(). The returned value indicates whether the pixmap has content or not. Showing a splash screen with null pixmap makes nothing to appear.
    J-P Nurmi

  7. #7
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SplashScreen isn't displayed

    So I have to do something like this:
    Qt Code:
    1. pixmap->isNull();
    To copy to clipboard, switch view to plain text mode 
    Yes?

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: SplashScreen isn't displayed

    Did you try to compile it? Variable pixmap is not a pointer so it would be pixmap.isNull(). Check the return value with a debugger or print it to debug output.
    J-P Nurmi

  9. #9
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SplashScreen isn't displayed

    I placed this in main.cpp, and reached in console window:
    QObject::connect: No such signal QTimer::timeout()
    But even if there's no timeout() signal, it should show splash

  10. #10
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SplashScreen isn't displayed

    Sure it's something wrong with pixmap.
    Make sure you added the qrc to the project file and that you rebuild the project.

    Regards

  11. #11
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SplashScreen isn't displayed

    Call QApplication::processEvents() after the splash.show()... and read the docs next time ... a QWidget can't appear before the application event loop starts running unless :
    • It has an event loop of its own, just like QMessageBox
    • You manually force events processing


    If you want to display messages (or change the content of the splash in any way...) you'll have to call the same function after each change to allow propagation of show/hide/reisze/paint events...
    Current Qt projects : QCodeEdit, RotiDeCode

  12. #12
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SplashScreen isn't displayed

    You have in your code timeOut not timeout.
    I'm sure console said the same.

    Regards

  13. #13
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: SplashScreen isn't displayed

    Quote Originally Posted by fullmetalcoder View Post
    Call QApplication::processEvents() after the splash.show()... and read the docs next time ...
    Actually, processing pending events does not solve the problem. QCoreApplication::exec() is already called and the splash screen is shown by then, same time with the main window. It's just that the pixmap is not loaded correctly so no splash screen is shown either.
    J-P Nurmi

  14. #14
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: SplashScreen isn't displayed

    This seems to be a double thread. Please don't start new threads on exactly the same subject.
    J-P Nurmi

  15. #15
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SplashScreen isn't displayed

    Quote Originally Posted by jpn View Post
    This seems to be a double thread. Please don't start new threads on exactly the same subject.
    Yes, it seemed kind of familiar... The suggestions just came out, no thinking at all.

    Anyway, Sal, loose the resource file and put the png somewhere accessible, like "c:\\image.png" ( this is to make sure you don't mess up the path ), and load the pixmap like this:
    Qt Code:
    1. QPixmap pix = QPixmap( "c:\\image.png");
    To copy to clipboard, switch view to plain text mode 

    There is no room for mistakes here. If it still doesn't show, then try changing the window flags for the splash. But only if that doesn't work.

    Regards

  16. #16
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SplashScreen isn't displayed

    Quote Originally Posted by jpn View Post
    t's just that the pixmap is not loaded correctly so no splash screen is shown either.
    Good point! It might not be the problem here but AFAIK, by default, resources use UNIX-like path, i.e. there is a '/' at the begining...
    Current Qt projects : QCodeEdit, RotiDeCode

  17. #17
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SplashScreen isn't displayed

    Quote Originally Posted by fullmetalcoder View Post
    Good point! It might not be the problem here but AFAIK, by default, resources use UNIX-like path, i.e. there is a '/' at the begining...
    Yes, I guess this is it .
    Well, this and actually compiling the qrc.

  18. #18
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SplashScreen isn't displayed

    This is it. Now splash is displayed. So I have a wrong adress of image in resource file. Of course I have resource file included in my .pro file. But what's the correct adress of this image...hmm...

  19. #19
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: SplashScreen isn't displayed

    Quote Originally Posted by Salazaar View Post
    This is it. Now splash is displayed. So I have a wrong adress of image in resource file. Of course I have resource file included in my .pro file. But what's the correct adress of this image...hmm...
    This is what I was trying to help you to realize yourself. It would be great help for you to learn, if not how to use debugger for now, but at least how to print informative messages to debug output.
    J-P Nurmi

  20. #20
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SplashScreen isn't displayed

    D' you mean to use qDebug to see if pixmap.isNull() ?

Similar Threads

  1. Replies: 20
    Last Post: 15th August 2008, 23:19
  2. Images/icons. It's not displayed
    By LMZ in forum Qt Tools
    Replies: 37
    Last Post: 18th May 2007, 14:55
  3. JPEG Image isn't displayed!?
    By GodOfWar in forum Qt Programming
    Replies: 9
    Last Post: 16th April 2007, 15:01
  4. QLineEdit - Float number not displayed correct
    By morty in forum Qt Programming
    Replies: 3
    Last Post: 9th November 2006, 00:47

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.