Results 1 to 7 of 7

Thread: QSplashScreen transparncy

  1. #1
    Join Date
    Dec 2008
    Location
    PUNE (INDIA)
    Posts
    49
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSplashScreen transparncy

    Hi all Expert,
    I am designing a custom SplashScreen , I have set a pixmap to it which has some transparent part in it . I have loaded a new image to the splashScreen in its drawContents( ) function to certain location.
    But I am not able to set the splachscreen fully transparent so that i can see my desktopImage through it.I had tried several options mentioned in the forum but unfortunately that did'nt work.
    Please let me know where i am going wrong.
    .h file
    class CustomSplashScreenublic QSplashScreen
    {
    Q_OBJECT
    public:
    CustomSplashScreen(const QPixmap& pixmap);
    ~CustomSplashScreen();
    protected:
    virtual void drawContents(QPainter *painter);
    void paintEvent(QPaintEvent *event);
    };
    .cpp file
    CustomSplashScreen::CustomSplashScreen(const QPixmap& pixmap)
    {
    QSplashScreen::setPixmap(pixmap);
    }

    CustomSplashScreen::~CustomSplashScreen()
    {
    }

    void CustomSplashScreen::drawContents(QPainter *painter)
    {
    QImage image("://images/3.png");
    painter->drawImage(-2,-2,image);
    }

    void CustomSplashScreen:aintEvent(QPaintEvent *event)
    {
    QPainter *painter = new QPainter(this);
    setAttribute(Qt::WA_NoSystemBackground);
    }
    I want the result like final_Result_splashScreen.png
    Attached Images Attached Images
    Last edited by vajindarladdad; 12th October 2009 at 11:53.
    Thanks & Regards ,

    Vajindar Laddad .
    Trainee Developer.
    (INDIA).
    91+9325014248

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSplashScreen transparncy

    You need to call
    Qt Code:
    1. QSplashScreen::setMask()
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Dec 2008
    Location
    PUNE (INDIA)
    Posts
    49
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSplashScreen transparncy

    Hi Yogesh Sir,
    i tried to set the mask , when i set the mask the spashsceen.png which is used to in function setPixmap() is shown ,but 3.png which is used in drawContents () is not shown.
    Please let me know where i am going wrong.
    Thanks & Regards ,

    Vajindar Laddad .
    Trainee Developer.
    (INDIA).
    91+9325014248

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSplashScreen transparncy

    Make sure, your image is transparent.

  5. #5
    Join Date
    Dec 2008
    Location
    PUNE (INDIA)
    Posts
    49
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSplashScreen transparncy

    Yes sir, it is transparent.
    The thing is i am loading two images first is in constructor & second is in drawContents()
    The second image is partly on the first image.
    I have tried many options but unfortunately nothing worked.
    Please give me a hint.
    Thanks & Regards ,

    Vajindar Laddad .
    Trainee Developer.
    (INDIA).
    91+9325014248

  6. #6
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSplashScreen transparncy

    Please run and see this example, use attached image.
    Qt Code:
    1. #include <QApplication>
    2. #include <QLabel>
    3. #include <QBitmap>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. QLabel lbl;
    9. QPixmap pixmap("yell.png");
    10. lbl.setPixmap(pixmap);
    11. lbl.setMask(pixmap.mask());
    12. lbl.show();
    13. app.setQuitOnLastWindowClosed(true);
    14. return app.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  7. #7
    Join Date
    Dec 2008
    Location
    PUNE (INDIA)
    Posts
    49
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSplashScreen transparncy

    This one gives me perfect result that i want.
    But in my case insted of QLabel it is QSplashScreen ..and instead of 1 image i have used 2 images.
    What i have to do in this case ?
    Last edited by vajindarladdad; 12th October 2009 at 13:17.
    Thanks & Regards ,

    Vajindar Laddad .
    Trainee Developer.
    (INDIA).
    91+9325014248

Similar Threads

  1. QSplashScreen question
    By graciano in forum Qt Programming
    Replies: 7
    Last Post: 14th July 2009, 12:39
  2. QSplashscreen, Qt.WindowStaysOnTopHint And Title Bar
    By Kel Solaar in forum Qt Programming
    Replies: 2
    Last Post: 18th June 2009, 21:43
  3. QSplashScreen loading icon
    By talk2amulya in forum Qt Programming
    Replies: 7
    Last Post: 16th February 2009, 09:46
  4. Stylesheets on QSplashScreen
    By GuS in forum Qt Programming
    Replies: 0
    Last Post: 16th July 2008, 14:50
  5. QSplashScreen Weirdness
    By mclark in forum Qt Programming
    Replies: 11
    Last Post: 19th November 2007, 06:49

Tags for this Thread

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.