What if setStylesheet fails?



  • Hello,

    Assuming that, I am using qss file in my application.
    .qss file contains all the styles required for the application.

    And I use global pointer to set the stylesheet.

    qApp->setStyleSheet("blah.qss");
    

    My question is,
    What if I made a mistake in blah.qss. Or say if the file is corrupted?

    setStyleSheet is a void function, it does not return any error.

    Is there any way to catch the failure?

    Thank you!


  • Qt Champions 2016

    Well, during development, it will show error in "Application Output" but so far I did not find a good solution to check when deployed.

    It might be a good idea in final release to embed the file in qrc so it cannot be corrupted if that is an option.

    Alternative, you could have a hidden object
    and in the end of the stylesheet, alter some values for that widget
    that you can also access from code. That way you can check if it was applied.


Log in to reply
 

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