Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Graphical effect Glow increases startup time

    QML and Qt Quick
    2
    5
    399
    Loading More Posts
    • 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.
    • M
      markugra last edited by

      Hi there,

      I am working on a Qml application that contains many text fields that are supposed to show sensor values. In order to highlight the numbers in case the user clicks on them I implemented a "text glow" using the Glow effect of the QGraphicalEffects module. However, I noticed now that this causes a significant increase (+3 seconds) in the application's startup time and I was wondering why (the visibility property of the effect is set to false by default i.e. on startup) and if there is a way to improve it?

      Thanks in advance for any input!

      1 Reply Last reply Reply Quote 0
      • ODБOï
        ODБOï last edited by

        hi @markugra ;
        Could you please show your code ?

        1 Reply Last reply Reply Quote 0
        • M
          markugra last edited by

          Thanks for your response. Below you find the code of the component (i.e. a separate qml file) that I am using to display the numbers. This is used all over the place in my application (I cannot provide all code but I hope this is sufficient).

          import QtQuick 2.0
          import QtGraphicalEffects 1.0
          import "."
          
          Item{
              id: root
              property real number: 0.0
              property string prefix:""
              property string suffix:""
              property int precision: 2
              property alias font: numberText.font
              property alias color: numberText.color
              property alias horizontalAlignment: numberText.horizontalAlignment
              property bool glowOn: false
              implicitHeight: numberText.implicitHeight
              implicitWidth: numberText.implicitWidth
          
              Text{
                  id: numberText
                  anchors.fill: parent
                  text: root.prefix + Number(root.number).toLocaleString(Qt.locale(),"f",root.precision) + root.suffix
              }
              Glow {
                  id: textGlow
                  anchors.fill: numberText
                  radius: 8
                  samples: 1 + radius * 2
                  color: numberText.color 
                  spread :0.2
                  source: numberText
                  visible: root.glowOn
                  transparentBorder: true 
                  fast: true 
                  antialiasing: true
              }
          }
          
          1 Reply Last reply Reply Quote 0
          • ODБOï
            ODБOï last edited by

            Im not sure but maybe try enabled:visible

            You may be interested
            http://doc.qt.io/qt-5/qquickitem.html
            http://doc.qt.io/qt-5/qtquick-performance.html

            1 Reply Last reply Reply Quote 0
            • M
              markugra last edited by

              @LeLev: Thanks for your answer. Unfortunately, setting enabled to false does not have an effect on the startup time either.

              What I did do now is to create an additional separate Component that contains both the Text and Glow. Using a Loader, that Component is then loaded only when the glowOn property is set to true otherwise my file above just contains the Text component. It's not that elegant since I have to replace the Text with the same Text (+Glow), but it does the trick.

              1 Reply Last reply Reply Quote 1
              • First post
                Last post