Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSvgWidget blocking interaction with other widgets.
Forum Updated to NodeBB v4.3 + New Features

QSvgWidget blocking interaction with other widgets.

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 4 Posters 864 Views 1 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.
  • SPlattenS SPlatten

    This is the SVG:

    <svg id="svgLED" width="640" height="480" xmlns="http://www.w3.org/2000/svg">
      <defs>
        <linearGradient id="svg_6" x1="0" y1="0" x2="1" y2="0">
          <stop stop-color="#bfbfbf" offset="0"/>
          <stop stop-color="#404040" offset="1"/>
        </linearGradient>
        <linearGradient id="svg_11" x1="0" y1="0" x2="1" y2="1" spreadMethod="pad">
          <stop stop-color="#dd0000" stop-opacity="0.992188" offset="0"/>
          <stop stop-color="#820101" stop-opacity="0.988281" offset="1"/>
        </linearGradient>
        <linearGradient id="svg_14" x1="0" y1="0" x2="1" y2="1" spreadMethod="pad">
          <stop stop-color="#ffffff" stop-opacity="0.996094" offset="0"/>
          <stop stop-color="#d30606" stop-opacity="0.984375" offset="0.703125"/>
        </linearGradient>
      </defs>
      <g transform="translate(10,10) scale(.1)">
        <circle id="svgLED@[id]_c1" fill="url(#svg_6)" 
          	    stroke-width="17.5" stroke-linecap="round" 
    	    cx="320" cy="240" r="196.125" id="svg_3" 
    	    fill-opacity="0.77" transform="rotate(90, 320, 240)"/>
        <circle id="svgLED@[id]_c2" fill="url(#svg_6)" 
                stroke-width="17.5" stroke-linecap="round" 
                fill-opacity="0.64" cx="319.252837" cy="239.999045" 
                r="160" id="svg_7"/>
        <circle id="svgLED@[id]_c3" fill="url(#svg_11)" stroke-width="17.5" 
                stroke-linecap="round" cx="320.000535" cy="240.001698" r="150"/>
        <ellipse id="svgLED@[id]_e1" fill="url(#svg_14)" stroke-width="17.5" 
                stroke-linecap="round" cx="250.179609" cy="170.124194" 
                rx="75.675959" ry="44.402987" id="svg_20" 
                transform="rotate(-47.7626, 250.18, 170.125)"/>
      </g>
    </svg>
    

    This is the C++ that renders the widget:

    if ( pobjNode->strGetNodeName().compare(clsXMLnode::mscszNodeSVGroot) == 0 ) {
      QString strID = pobjNode->strGetAttribute(clsXMLnode::mscszAttrID);
    
      if ( strID.isEmpty() != true ) {
        clsXMLnode* pobjParent = pobjNode->pobjGetGUIParent();
    
        if ( pobjParent != nullptr ) {
          QWidget* pobjParWidget = pobjParent->pobjGetWidget();
    
          if ( pobjParWidget != nullptr ) {
            QByteArray bytArrSVG = pobjNode->bytArrDocument();
            QSvgWidget* pobjSVGwidget = new QSvgWidget(pobjParWidget);
            pobjSVGwidget->load(bytArrSVG);
            pobjSVGwidget->show();
          }
        }
      }
    }
    

    The SVG is intentionally rendered very small, so it appears as a very small image at the top left of the window. The problem is that with this widget present everything else in the window is blocked, what I mean is that there are buttons under the SVG and also text edit widgets, none of these will accept clicks whilst the SVG is visible. The only widget that does continue to work is a slider on the right of the window.
    Screenshot 2020-08-27 at 08.51.00.png
    The screenshot shows a demo, the red LED is the SVG, no other widgets in the window work except the slider, yet if I remove the SVG everything works.

    What is wrong?

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @SPlatten How big is pobjSVGwidget? Maybe it covers all these other widgets? What is pobjParWidget?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    SPlattenS 1 Reply Last reply
    2
    • jsulmJ jsulm

      @SPlatten How big is pobjSVGwidget? Maybe it covers all these other widgets? What is pobjParWidget?

      SPlattenS Offline
      SPlattenS Offline
      SPlatten
      wrote on last edited by SPlatten
      #3

      @jsulm The SVG widget is shown in the screen shot I added, its very small.

      pobjParent is a pointer to the Window node, pobjParWidget is the widget associated with the window node.

      Kind Regards,
      Sy

      jsulmJ 1 Reply Last reply
      0
      • SPlattenS SPlatten

        @jsulm The SVG widget is shown in the screen shot I added, its very small.

        pobjParent is a pointer to the Window node, pobjParWidget is the widget associated with the window node.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @SPlatten said in QSvgWidget blocking interaction with other widgets.:

        its very small

        The icon is very small, but not necessarily the widget.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        SPlattenS 1 Reply Last reply
        1
        • jsulmJ jsulm

          @SPlatten said in QSvgWidget blocking interaction with other widgets.:

          its very small

          The icon is very small, but not necessarily the widget.

          SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by SPlatten
          #5

          @jsulm , how can I tell? I am just parsing the parent to the SVG widget, I though the QSvgWidget would get its geometry from the SVG itself?

          I'm scaling the SVG in the transform, however having just added debug to display the geometry, this doesn't seem to effect the width and height of the SVG which is still 640x480.

          Kind Regards,
          Sy

          jsulmJ B 2 Replies Last reply
          0
          • SPlattenS SPlatten

            @jsulm , how can I tell? I am just parsing the parent to the SVG widget, I though the QSvgWidget would get its geometry from the SVG itself?

            I'm scaling the SVG in the transform, however having just added debug to display the geometry, this doesn't seem to effect the width and height of the SVG which is still 640x480.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by jsulm
            #6

            @SPlatten said in QSvgWidget blocking interaction with other widgets.:

            I though the QSvgWidget would get its geometry from the SVG itself?

            That I don't know. You could try to set fix size on SVG widget and see whether other widgets work then (just to see whether my guess is correct).

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            SPlattenS 1 Reply Last reply
            2
            • jsulmJ jsulm

              @SPlatten said in QSvgWidget blocking interaction with other widgets.:

              I though the QSvgWidget would get its geometry from the SVG itself?

              That I don't know. You could try to set fix size on SVG widget and see whether other widgets work then (just to see whether my guess is correct).

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #7

              @jsulm I've just removed the width and height attributes from the SVG, now everything works perfectly.

              Kind Regards,
              Sy

              jsulmJ 1 Reply Last reply
              2
              • SPlattenS SPlatten

                @jsulm I've just removed the width and height attributes from the SVG, now everything works perfectly.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @SPlatten That answers your question: "I though the QSvgWidget would get its geometry from the SVG itself?" :-)

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                SPlattenS 1 Reply Last reply
                2
                • SPlattenS SPlatten

                  @jsulm , how can I tell? I am just parsing the parent to the SVG widget, I though the QSvgWidget would get its geometry from the SVG itself?

                  I'm scaling the SVG in the transform, however having just added debug to display the geometry, this doesn't seem to effect the width and height of the SVG which is still 640x480.

                  B Offline
                  B Offline
                  Bonnie
                  wrote on last edited by
                  #9

                  @SPlatten said in QSvgWidget blocking interaction with other widgets.:

                  I though the QSvgWidget would get its geometry from the SVG itself?

                  No, it would not. It will only update the size hint of the widget.
                  You are supposed to adjust the size yourself.

                  1 Reply Last reply
                  1
                  • jsulmJ jsulm

                    @SPlatten That answers your question: "I though the QSvgWidget would get its geometry from the SVG itself?" :-)

                    SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by
                    #10

                    @jsulm , yes, but shouldn't that take into account any scaling transformation?

                    Kind Regards,
                    Sy

                    jsulmJ 1 Reply Last reply
                    0
                    • SPlattenS SPlatten

                      @jsulm , yes, but shouldn't that take into account any scaling transformation?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      @SPlatten Scaling is something you usually have to explicitly do/trigger. QLabel will not do scaling by default, for example, if I remember correctly.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      JoeCFDJ 1 Reply Last reply
                      3
                      • jsulmJ jsulm

                        @SPlatten Scaling is something you usually have to explicitly do/trigger. QLabel will not do scaling by default, for example, if I remember correctly.

                        JoeCFDJ Offline
                        JoeCFDJ Offline
                        JoeCFD
                        wrote on last edited by
                        #12

                        @jsulm qlabel->setScaledContents(bool) default is false;

                        1 Reply Last reply
                        3

                        • Login

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