Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. app.setStyleSheet performance
Forum Updated to NodeBB v4.3 + New Features

app.setStyleSheet performance

Scheduled Pinned Locked Moved Unsolved Language Bindings
2 Posts 2 Posters 1.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lvlvlvl
    wrote on last edited by
    #1

    In PySide calling setStyleSheet at application level seems to slow drastically the execution of the application.
    The module cProfile allows to evaluate the impact of setStyleSheet.
    Without calling setStyleSheet at application level, opening a subWindow takes 0.091 seconds and cProfile reports :

        2795 function calls in 0.091 seconds
    

    Ordered by: internal time

    ncalls tottime percall cumtime percall filename:lineno(function)
    1 0.015 0.015 0.021 0.021 monaffaire.py:13(setupUi)
    1 0.011 0.011 0.011 0.011 {method 'sizeHint' of 'PySide.QtGui.QMdiSubWindow' objects}
    1 0.005 0.005 0.005 0.005 {method 'show' of 'PySide.QtGui.QWidget' objects}
    1 0.005 0.005 0.005 0.005 {method 'findChildren' of 'PySide.QtCore.QObject' objects}
    1 0.005 0.005 0.005 0.005 {method 'setTable' of 'PySide.QtSql.QSqlTableModel' objects}

    When adding a dumb stylesheet by app.setStyleSheet("/* */"), the same subWindow opens in 0.193 seconds and cProfile reports :

        2978 function calls in 0.193 seconds
    

    Ordered by: internal time

    ncalls tottime percall cumtime percall filename:lineno(function)
    1 0.050 0.050 0.051 0.051 {method 'addSubWindow' of 'PySide.QtGui.QMdiArea' objects}
    1 0.021 0.021 0.021 0.021 {method 'setWidget' of 'PySide.QtGui.QMdiSubWindow' objects}
    1 0.021 0.021 0.021 0.021 {method 'sizeHint' of 'PySide.QtGui.QMdiSubWindow' objects}
    1 0.019 0.019 0.042 0.042 monaffaire.py:13(setupUi)
    4 0.018 0.004 0.018 0.004 {method 'addTab' of 'PySide.QtGui.QTabWidget' objects}

    Is there a way to integrate stylesheet at application level without reducing the performance ?
    When calling setStyleSheet at QWidget level, no loss of performance seems to occur, but this way does not permit to regroup all stylesheet instructions in one external qss file.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Putting your stylesheet at the application level (especially if the one your wrote) means that each and every widget might be customised which requires changing the style used to draw the widget. So you should be careful with what you put in your stylesheet.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved