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. How to make a SVG at tab Widget ?
Forum Updated to NodeBB v4.3 + New Features

How to make a SVG at tab Widget ?

Scheduled Pinned Locked Moved Solved General and Desktop
55 Posts 6 Posters 10.6k 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.
  • R RiceBall

    @Pradeep-P-N said in How to make a SVG at tab Widget ?:

    Hi @RiceBall

    Scene size please check minimumRenderSize.

    QWidget has an option to set the windowOpacity.

    Below is sample code for defining the size and transparency...

    QGraphicsView *gView = new QGraphicsView(this);
    QGraphicsScene *scene = new QGraphicsScene;
    
    QSvgWidget *svgWid = new QSvgWidget(":/Freesample.svg");
    svgWid->setWindowOpacity(0.5); // Change as needed
    scene->addWidget(svgWid);
    
    gView->resize(350, 350);
    gView->setScene(scene);
    

    Output:

    Opacity : 0.5

    0_1559800637737_1.png

    Without Opacity:

    0_1559800660243_2.png

    All the best.

    Thank you for your answer.
    I have some problem.

    1. I can't loading several SVG. If I loading several file. It just only show last one.
    2. I use UI screen to set background-color:black. And I am sure my SVG is none background color.
      But when I loading it . It always show white background.

    Result
    0_1559802305958_cd108fdd-fff2-4022-9fa8-5e0f63edba2a-image.png

        QSvgWidget * svgWid1 = new QSvgWidget("../iHMI_2/splash1.svg");
        QSvgWidget * svgWid2 = new QSvgWidget("../iHMI_2/splash2.svg");
        QSvgWidget * svgWid3 = new QSvgWidget("../iHMI_2/splash3.svg");
        QSvgWidget * svgWid4 = new QSvgWidget("../iHMI_2/splash4.svg");
    
        QGraphicsScene *scene = new QGraphicsScene;
    
        scene->addWidget(svgWid1);
        scene->addWidget(svgWid2);
        scene->addWidget(svgWid3);
        scene->addWidget(svgWid4);
    
        ui->graphicsView->setScene(scene);
    
    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #30

    @RiceBall said in How to make a SVG at tab Widget ?:

    I can't loading several SVG. If I loading several file. It just only show last one.

    Is the code at the bottom of your post the one you're using to load SVGs? Maybe they are simply all at same position, so you only see the last one?

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

    R 1 Reply Last reply
    1
    • jsulmJ jsulm

      @RiceBall said in How to make a SVG at tab Widget ?:

      I can't loading several SVG. If I loading several file. It just only show last one.

      Is the code at the bottom of your post the one you're using to load SVGs? Maybe they are simply all at same position, so you only see the last one?

      R Offline
      R Offline
      RiceBall
      wrote on last edited by
      #31

      @jsulm said in How to make a SVG at tab Widget ?:

      @RiceBall said in How to make a SVG at tab Widget ?:

      I can't loading several SVG. If I loading several file. It just only show last one.

      Is the code at the bottom of your post the one you're using to load SVGs? Maybe they are simply all at same position, so you only see the last one?

      No. They are at different position.
      It looks like below.
      0_1559806084717_6baf5868-11e9-42de-a210-df2ab38bf87c-image.png

      Pradeep P NP 1 Reply Last reply
      0
      • R RiceBall

        @jsulm said in How to make a SVG at tab Widget ?:

        @RiceBall said in How to make a SVG at tab Widget ?:

        I can't loading several SVG. If I loading several file. It just only show last one.

        Is the code at the bottom of your post the one you're using to load SVGs? Maybe they are simply all at same position, so you only see the last one?

        No. They are at different position.
        It looks like below.
        0_1559806084717_6baf5868-11e9-42de-a210-df2ab38bf87c-image.png

        Pradeep P NP Offline
        Pradeep P NP Offline
        Pradeep P N
        wrote on last edited by
        #32

        Hi @RiceBall
        Can you please create the CustomWidget inheriting from QWidget with Some Layout in it to align the SVG contents.

        // Please customize the Class as per your requirement.
        // I just provided some dummy sample code.
        

        Example:
        class CustomWidget : public QWidget

            QGridLayout *glyt = new QGridLayout;
        
            QSvgWidget *svgWid1 = new QSvgWidget(":/Freesample.svg");
            QSvgWidget *svgWid2 = new QSvgWidget(":/Freesample.svg");
            QSvgWidget *svgWid3 = new QSvgWidget(":/Freesample.svg");
            QSvgWidget *svgWid4 = new QSvgWidget(":/Freesample.svg");
        
            glyt->addWidget(svgWid1);
            glyt->addWidget(svgWid2);
            glyt->addWidget(svgWid3);
            glyt->addWidget(svgWid4);
        
            this->setLayout(glyt);
        
        

        Then use the CustomWidget as

            CustomWidget *csw = new CustomWidget;
        
            scene->addWidget(csw);
        

        Output:

        0_1559809391960_4.png

        Might help you.

        All the best.

        Pradeep Nimbalkar.
        Upvote the answer(s) that helped you to solve the issue...
        Keep code clean.

        R 1 Reply Last reply
        2
        • Pradeep P NP Pradeep P N

          Hi @RiceBall
          Can you please create the CustomWidget inheriting from QWidget with Some Layout in it to align the SVG contents.

          // Please customize the Class as per your requirement.
          // I just provided some dummy sample code.
          

          Example:
          class CustomWidget : public QWidget

              QGridLayout *glyt = new QGridLayout;
          
              QSvgWidget *svgWid1 = new QSvgWidget(":/Freesample.svg");
              QSvgWidget *svgWid2 = new QSvgWidget(":/Freesample.svg");
              QSvgWidget *svgWid3 = new QSvgWidget(":/Freesample.svg");
              QSvgWidget *svgWid4 = new QSvgWidget(":/Freesample.svg");
          
              glyt->addWidget(svgWid1);
              glyt->addWidget(svgWid2);
              glyt->addWidget(svgWid3);
              glyt->addWidget(svgWid4);
          
              this->setLayout(glyt);
          
          

          Then use the CustomWidget as

              CustomWidget *csw = new CustomWidget;
          
              scene->addWidget(csw);
          

          Output:

          0_1559809391960_4.png

          Might help you.

          All the best.

          R Offline
          R Offline
          RiceBall
          wrote on last edited by
          #33

          @Pradeep-P-N said in How to make a SVG at tab Widget ?:

          Hi @RiceBall
          Can you please create the CustomWidget inheriting from QWidget with Some Layout in it to align the SVG contents.

          // Please customize the Class as per your requirement.
          // I just provided some dummy sample code.
          

          Example:
          class CustomWidget : public QWidget

              QGridLayout *glyt = new QGridLayout;
          
              QSvgWidget *svgWid1 = new QSvgWidget(":/Freesample.svg");
              QSvgWidget *svgWid2 = new QSvgWidget(":/Freesample.svg");
              QSvgWidget *svgWid3 = new QSvgWidget(":/Freesample.svg");
              QSvgWidget *svgWid4 = new QSvgWidget(":/Freesample.svg");
          
              glyt->addWidget(svgWid1);
              glyt->addWidget(svgWid2);
              glyt->addWidget(svgWid3);
              glyt->addWidget(svgWid4);
          
              this->setLayout(glyt);
          
          

          Then use the CustomWidget as

              CustomWidget *csw = new CustomWidget;
          
              scene->addWidget(csw);
          

          Output:

          0_1559809391960_4.png

          Might help you.

          All the best.

          Sorry, I never use that.
          Your meaning is I create a new class at mainwindow.h ??

          class CustomWidget : public QWidget
          {}
          

          where can I code it ?mainwindow.h or mainwindow.cpp

          QGridLayout *glyt = new QGridLayout;
          
             QSvgWidget *svgWid1 = new QSvgWidget("../iHMI_2/splash1.svg");
             QSvgWidget *svgWid2 = new QSvgWidget("../iHMI_2/splash2.svg");
             QSvgWidget *svgWid3 = new QSvgWidget("../iHMI_2/splash3.svg");
             QSvgWidget *svgWid4 = new QSvgWidget("../iHMI_2/splash4.svg");
          
             glyt->addWidget(svgWid1);
             glyt->addWidget(svgWid2);
             glyt->addWidget(svgWid3);
             glyt->addWidget(svgWid4);
          
             this->setLayout(glyt);
          
          jsulmJ 1 Reply Last reply
          0
          • R RiceBall

            @Pradeep-P-N said in How to make a SVG at tab Widget ?:

            Hi @RiceBall
            Can you please create the CustomWidget inheriting from QWidget with Some Layout in it to align the SVG contents.

            // Please customize the Class as per your requirement.
            // I just provided some dummy sample code.
            

            Example:
            class CustomWidget : public QWidget

                QGridLayout *glyt = new QGridLayout;
            
                QSvgWidget *svgWid1 = new QSvgWidget(":/Freesample.svg");
                QSvgWidget *svgWid2 = new QSvgWidget(":/Freesample.svg");
                QSvgWidget *svgWid3 = new QSvgWidget(":/Freesample.svg");
                QSvgWidget *svgWid4 = new QSvgWidget(":/Freesample.svg");
            
                glyt->addWidget(svgWid1);
                glyt->addWidget(svgWid2);
                glyt->addWidget(svgWid3);
                glyt->addWidget(svgWid4);
            
                this->setLayout(glyt);
            
            

            Then use the CustomWidget as

                CustomWidget *csw = new CustomWidget;
            
                scene->addWidget(csw);
            

            Output:

            0_1559809391960_4.png

            Might help you.

            All the best.

            Sorry, I never use that.
            Your meaning is I create a new class at mainwindow.h ??

            class CustomWidget : public QWidget
            {}
            

            where can I code it ?mainwindow.h or mainwindow.cpp

            QGridLayout *glyt = new QGridLayout;
            
               QSvgWidget *svgWid1 = new QSvgWidget("../iHMI_2/splash1.svg");
               QSvgWidget *svgWid2 = new QSvgWidget("../iHMI_2/splash2.svg");
               QSvgWidget *svgWid3 = new QSvgWidget("../iHMI_2/splash3.svg");
               QSvgWidget *svgWid4 = new QSvgWidget("../iHMI_2/splash4.svg");
            
               glyt->addWidget(svgWid1);
               glyt->addWidget(svgWid2);
               glyt->addWidget(svgWid3);
               glyt->addWidget(svgWid4);
            
               this->setLayout(glyt);
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #34

            @RiceBall said in How to make a SVG at tab Widget ?:

            where can I code it ?mainwindow.h or mainwindow.cpp

            in customwidget.h + customwidget.cpp...

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

            R 1 Reply Last reply
            1
            • jsulmJ jsulm

              @RiceBall said in How to make a SVG at tab Widget ?:

              where can I code it ?mainwindow.h or mainwindow.cpp

              in customwidget.h + customwidget.cpp...

              R Offline
              R Offline
              RiceBall
              wrote on last edited by RiceBall
              #35

              @jsulm said in How to make a SVG at tab Widget ?:

              @RiceBall said in How to make a SVG at tab Widget ?:

              where can I code it ?mainwindow.h or mainwindow.cpp

              in customwidget.h + customwidget.cpp...

              So I create new customwidget.h & customwidget.cpp
              And coding like below.
              Is it right ??
              Because at mainwindow.cpp it show "use of undeclared identifier 'scene'".

              customwidget.h

              #ifndef CUSTOMWIDGET_H
              #define CUSTOMWIDGET_H
              #include <QWidget>
              
              class customwidget : public QWidget
              {
                  Q_OBJECT
              public:
                  explicit customwidget(QWidget *parent = nullptr);
              signals:
              public slots:
              };
              
              #endif // CUSTOMWIDGET_H
              
              

              customwidget.cpp

              #include "customwidget.h"
              #include <QGridLayout>
              #include <QSvgWidget>
              
              
              customwidget::customwidget(QWidget *parent) : QWidget(parent)
              {
                  QGridLayout *glyt = new QGridLayout;
                  
                     QSvgWidget *svgWid1 = new QSvgWidget("../iHMI_2/splash1.svg");
                     QSvgWidget *svgWid2 = new QSvgWidget("../iHMI_2/splash2.svg");
                     QSvgWidget *svgWid3 = new QSvgWidget("../iHMI_2/splash3.svg");
                     QSvgWidget *svgWid4 = new QSvgWidget("../iHMI_2/splash4.svg");
                  
                     glyt->addWidget(svgWid1);
                     glyt->addWidget(svgWid2);
                     glyt->addWidget(svgWid3);
                     glyt->addWidget(svgWid4);
                  
                     this->setLayout(glyt);
              }
              

              mainwindow.cpp

              #include "mainwindow.h"
              #include "ui_mainwindow.h"
              #include <QLabel>
              #include "customwidget.h"
              
              
              //#include <QGraphicsScene>
              //#include <QGraphicsView>
              //#include <QtSvg/QSvgWidget>
              //#include <QMovie>
              //#include <QPixmap>
              
              
              MainWindow::MainWindow(QWidget *parent) :
                  QMainWindow(parent),
                  ui(new Ui::MainWindow)
              {
                  ui->setupUi(this);
                  CustomWidget *csw = new CustomWidget;
                  scene->addWidget(csw);
              
              
              R jsulmJ 2 Replies Last reply
              0
              • R RiceBall

                @jsulm said in How to make a SVG at tab Widget ?:

                @RiceBall said in How to make a SVG at tab Widget ?:

                where can I code it ?mainwindow.h or mainwindow.cpp

                in customwidget.h + customwidget.cpp...

                So I create new customwidget.h & customwidget.cpp
                And coding like below.
                Is it right ??
                Because at mainwindow.cpp it show "use of undeclared identifier 'scene'".

                customwidget.h

                #ifndef CUSTOMWIDGET_H
                #define CUSTOMWIDGET_H
                #include <QWidget>
                
                class customwidget : public QWidget
                {
                    Q_OBJECT
                public:
                    explicit customwidget(QWidget *parent = nullptr);
                signals:
                public slots:
                };
                
                #endif // CUSTOMWIDGET_H
                
                

                customwidget.cpp

                #include "customwidget.h"
                #include <QGridLayout>
                #include <QSvgWidget>
                
                
                customwidget::customwidget(QWidget *parent) : QWidget(parent)
                {
                    QGridLayout *glyt = new QGridLayout;
                    
                       QSvgWidget *svgWid1 = new QSvgWidget("../iHMI_2/splash1.svg");
                       QSvgWidget *svgWid2 = new QSvgWidget("../iHMI_2/splash2.svg");
                       QSvgWidget *svgWid3 = new QSvgWidget("../iHMI_2/splash3.svg");
                       QSvgWidget *svgWid4 = new QSvgWidget("../iHMI_2/splash4.svg");
                    
                       glyt->addWidget(svgWid1);
                       glyt->addWidget(svgWid2);
                       glyt->addWidget(svgWid3);
                       glyt->addWidget(svgWid4);
                    
                       this->setLayout(glyt);
                }
                

                mainwindow.cpp

                #include "mainwindow.h"
                #include "ui_mainwindow.h"
                #include <QLabel>
                #include "customwidget.h"
                
                
                //#include <QGraphicsScene>
                //#include <QGraphicsView>
                //#include <QtSvg/QSvgWidget>
                //#include <QMovie>
                //#include <QPixmap>
                
                
                MainWindow::MainWindow(QWidget *parent) :
                    QMainWindow(parent),
                    ui(new Ui::MainWindow)
                {
                    ui->setupUi(this);
                    CustomWidget *csw = new CustomWidget;
                    scene->addWidget(csw);
                
                
                R Offline
                R Offline
                RiceBall
                wrote on last edited by
                #36

                @Pradeep-P-N
                Is this your meaning like above reply?

                mrjjM Pradeep P NP 2 Replies Last reply
                0
                • R RiceBall

                  @Pradeep-P-N
                  Is this your meaning like above reply?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #37

                  @RiceBall
                  Hi
                  Yes, he meant to make such a custom class.

                  However, in MainWindow, you just use a scene which is undefined. (or did u add it as member ?)
                  You should at least do
                  QGraphicsScene *scene = new QGraphicsScene;
                  first.

                  1 Reply Last reply
                  1
                  • R RiceBall

                    @Pradeep-P-N
                    Is this your meaning like above reply?

                    Pradeep P NP Offline
                    Pradeep P NP Offline
                    Pradeep P N
                    wrote on last edited by Pradeep P N
                    #38

                    Hi @RiceBall
                    Sorry was bit busy, Yes follow below instructions.

                    • Create a Class inheriting from QWidget (Example as above code class CustomWidget : public QWidget)
                    • Use the QLayout Class options available (Use whichever suitable to your UI Arrangement)
                    • Once you have the CustomeWidget ready you can use this Class as the widget for Graphics Scene
                    QGraphicsScene *scene = new QGraphicsScene
                    CustomWidget *csw = new CustomWidget;
                    scene->addWidget(csw);
                    
                    • Optimize your code and you can achieve the result you are looking for.

                    All the best.

                    Pradeep Nimbalkar.
                    Upvote the answer(s) that helped you to solve the issue...
                    Keep code clean.

                    R 1 Reply Last reply
                    4
                    • Pradeep P NP Pradeep P N

                      Hi @RiceBall
                      Sorry was bit busy, Yes follow below instructions.

                      • Create a Class inheriting from QWidget (Example as above code class CustomWidget : public QWidget)
                      • Use the QLayout Class options available (Use whichever suitable to your UI Arrangement)
                      • Once you have the CustomeWidget ready you can use this Class as the widget for Graphics Scene
                      QGraphicsScene *scene = new QGraphicsScene
                      CustomWidget *csw = new CustomWidget;
                      scene->addWidget(csw);
                      
                      • Optimize your code and you can achieve the result you are looking for.

                      All the best.

                      R Offline
                      R Offline
                      RiceBall
                      wrote on last edited by
                      #39

                      @mrjj
                      @Pradeep-P-N said in How to make a SVG at tab Widget ?:

                      QGraphicsScene *scene = new QGraphicsScene

                      I try to fix code and test it.
                      But I can see it loading something but is white.

                          ui->setupUi(this);
                          CustomWidget *csw = new CustomWidget;
                          QGraphicsScene *scene = new QGraphicsScene;
                          scene->addWidget(csw);
                          ui->graphicsView->setScene(scene);
                      
                      

                      0_1560181567099_73e060c5-017f-4def-b7fa-e60b4fcfe5b0-image.png

                      0_1560181613760_02ca1518-6496-4026-a90a-3bd98d93974a-image.png

                      1 Reply Last reply
                      0
                      • R RiceBall

                        @jsulm said in How to make a SVG at tab Widget ?:

                        @RiceBall said in How to make a SVG at tab Widget ?:

                        where can I code it ?mainwindow.h or mainwindow.cpp

                        in customwidget.h + customwidget.cpp...

                        So I create new customwidget.h & customwidget.cpp
                        And coding like below.
                        Is it right ??
                        Because at mainwindow.cpp it show "use of undeclared identifier 'scene'".

                        customwidget.h

                        #ifndef CUSTOMWIDGET_H
                        #define CUSTOMWIDGET_H
                        #include <QWidget>
                        
                        class customwidget : public QWidget
                        {
                            Q_OBJECT
                        public:
                            explicit customwidget(QWidget *parent = nullptr);
                        signals:
                        public slots:
                        };
                        
                        #endif // CUSTOMWIDGET_H
                        
                        

                        customwidget.cpp

                        #include "customwidget.h"
                        #include <QGridLayout>
                        #include <QSvgWidget>
                        
                        
                        customwidget::customwidget(QWidget *parent) : QWidget(parent)
                        {
                            QGridLayout *glyt = new QGridLayout;
                            
                               QSvgWidget *svgWid1 = new QSvgWidget("../iHMI_2/splash1.svg");
                               QSvgWidget *svgWid2 = new QSvgWidget("../iHMI_2/splash2.svg");
                               QSvgWidget *svgWid3 = new QSvgWidget("../iHMI_2/splash3.svg");
                               QSvgWidget *svgWid4 = new QSvgWidget("../iHMI_2/splash4.svg");
                            
                               glyt->addWidget(svgWid1);
                               glyt->addWidget(svgWid2);
                               glyt->addWidget(svgWid3);
                               glyt->addWidget(svgWid4);
                            
                               this->setLayout(glyt);
                        }
                        

                        mainwindow.cpp

                        #include "mainwindow.h"
                        #include "ui_mainwindow.h"
                        #include <QLabel>
                        #include "customwidget.h"
                        
                        
                        //#include <QGraphicsScene>
                        //#include <QGraphicsView>
                        //#include <QtSvg/QSvgWidget>
                        //#include <QMovie>
                        //#include <QPixmap>
                        
                        
                        MainWindow::MainWindow(QWidget *parent) :
                            QMainWindow(parent),
                            ui(new Ui::MainWindow)
                        {
                            ui->setupUi(this);
                            CustomWidget *csw = new CustomWidget;
                            scene->addWidget(csw);
                        
                        
                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #40

                        @RiceBall said in How to make a SVG at tab Widget ?:

                        QSvgWidget *svgWid1 = new QSvgWidget("../iHMI_2/splash1.svg");
                        QSvgWidget *svgWid2 = new QSvgWidget("../iHMI_2/splash2.svg");
                        QSvgWidget *svgWid3 = new QSvgWidget("../iHMI_2/splash3.svg");
                        QSvgWidget *svgWid4 = new QSvgWidget("../iHMI_2/splash4.svg");

                        You're using relative paths: did you make sure the files are actually found at runtime?

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

                        R 1 Reply Last reply
                        2
                        • jsulmJ jsulm

                          @RiceBall said in How to make a SVG at tab Widget ?:

                          QSvgWidget *svgWid1 = new QSvgWidget("../iHMI_2/splash1.svg");
                          QSvgWidget *svgWid2 = new QSvgWidget("../iHMI_2/splash2.svg");
                          QSvgWidget *svgWid3 = new QSvgWidget("../iHMI_2/splash3.svg");
                          QSvgWidget *svgWid4 = new QSvgWidget("../iHMI_2/splash4.svg");

                          You're using relative paths: did you make sure the files are actually found at runtime?

                          R Offline
                          R Offline
                          RiceBall
                          wrote on last edited by
                          #41

                          @jsulm said in How to make a SVG at tab Widget ?:

                          @RiceBall said in How to make a SVG at tab Widget ?:

                          QSvgWidget *svgWid1 = new QSvgWidget("../iHMI_2/splash1.svg");
                          QSvgWidget *svgWid2 = new QSvgWidget("../iHMI_2/splash2.svg");
                          QSvgWidget *svgWid3 = new QSvgWidget("../iHMI_2/splash3.svg");
                          QSvgWidget *svgWid4 = new QSvgWidget("../iHMI_2/splash4.svg");

                          You're using relative paths: did you make sure the files are actually found at runtime?

                          I changed to the absolute path.
                          The problem is the same.
                          Does it have any possible I coding wrong ??

                          0_1560302175659_10b76459-1af8-4343-987b-48bda39c8a98-image.png

                          0_1560302272379_4276155c-ef46-495f-b3b5-0072c3ef9c1b-image.png

                          jsulmJ 1 Reply Last reply
                          0
                          • R RiceBall

                            @jsulm said in How to make a SVG at tab Widget ?:

                            @RiceBall said in How to make a SVG at tab Widget ?:

                            QSvgWidget *svgWid1 = new QSvgWidget("../iHMI_2/splash1.svg");
                            QSvgWidget *svgWid2 = new QSvgWidget("../iHMI_2/splash2.svg");
                            QSvgWidget *svgWid3 = new QSvgWidget("../iHMI_2/splash3.svg");
                            QSvgWidget *svgWid4 = new QSvgWidget("../iHMI_2/splash4.svg");

                            You're using relative paths: did you make sure the files are actually found at runtime?

                            I changed to the absolute path.
                            The problem is the same.
                            Does it have any possible I coding wrong ??

                            0_1560302175659_10b76459-1af8-4343-987b-48bda39c8a98-image.png

                            0_1560302272379_4276155c-ef46-495f-b3b5-0072c3ef9c1b-image.png

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

                            @RiceBall You can also check this:

                            • Get the renderer from the SVG widget using https://doc.qt.io/qt-5/qsvgwidget.html#renderer
                            • Check what https://doc.qt.io/qt-5/qsvgrenderer.html#isValid returns

                            And also call show() on each SVG widget you're creating.

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

                            R 1 Reply Last reply
                            0
                            • jsulmJ jsulm

                              @RiceBall You can also check this:

                              • Get the renderer from the SVG widget using https://doc.qt.io/qt-5/qsvgwidget.html#renderer
                              • Check what https://doc.qt.io/qt-5/qsvgrenderer.html#isValid returns

                              And also call show() on each SVG widget you're creating.

                              R Offline
                              R Offline
                              RiceBall
                              wrote on last edited by
                              #43

                              @jsulm said in How to make a SVG at tab Widget ?:

                              @RiceBall You can also check this:

                              • Get the renderer from the SVG widget using https://doc.qt.io/qt-5/qsvgwidget.html#renderer
                              • Check what https://doc.qt.io/qt-5/qsvgrenderer.html#isValid returns

                              And also call show() on each SVG widget you're creating.

                              How could I use it ??
                              Can you make a sample for me ??
                              Thank you.

                              jsulmJ 1 Reply Last reply
                              0
                              • R RiceBall

                                @jsulm said in How to make a SVG at tab Widget ?:

                                @RiceBall You can also check this:

                                • Get the renderer from the SVG widget using https://doc.qt.io/qt-5/qsvgwidget.html#renderer
                                • Check what https://doc.qt.io/qt-5/qsvgrenderer.html#isValid returns

                                And also call show() on each SVG widget you're creating.

                                How could I use it ??
                                Can you make a sample for me ??
                                Thank you.

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

                                @RiceBall said in How to make a SVG at tab Widget ?:

                                How could I use it ??

                                Come on, what's difficult about it?!

                                svgWid1->show();
                                ...
                                qDebug() << svgWid1->renderer()->isValid();
                                

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

                                R 1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @RiceBall said in How to make a SVG at tab Widget ?:

                                  How could I use it ??

                                  Come on, what's difficult about it?!

                                  svgWid1->show();
                                  ...
                                  qDebug() << svgWid1->renderer()->isValid();
                                  
                                  R Offline
                                  R Offline
                                  RiceBall
                                  wrote on last edited by
                                  #45

                                  @jsulm said in How to make a SVG at tab Widget ?:

                                  @RiceBall said in How to make a SVG at tab Widget ?:

                                  How could I use it ??

                                  Come on, what's difficult about it?!

                                  svgWid1->show();
                                  ...
                                  qDebug() << svgWid1->renderer()->isValid();
                                  

                                  Sorry to ask too much easily question.
                                  Because I just started learning QT and C++.
                                  So some documents are difficult for me.

                                  I try to add code like you writing at customwidget.cpp
                                  But I can't see any different.

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • R RiceBall

                                    @jsulm said in How to make a SVG at tab Widget ?:

                                    @RiceBall said in How to make a SVG at tab Widget ?:

                                    How could I use it ??

                                    Come on, what's difficult about it?!

                                    svgWid1->show();
                                    ...
                                    qDebug() << svgWid1->renderer()->isValid();
                                    

                                    Sorry to ask too much easily question.
                                    Because I just started learning QT and C++.
                                    So some documents are difficult for me.

                                    I try to add code like you writing at customwidget.cpp
                                    But I can't see any different.

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

                                    @RiceBall OK, no problem.
                                    The second line should print something to the console - what do you see there ("Application Output" tab in QtCreator)?

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

                                    R 1 Reply Last reply
                                    0
                                    • jsulmJ jsulm

                                      @RiceBall OK, no problem.
                                      The second line should print something to the console - what do you see there ("Application Output" tab in QtCreator)?

                                      R Offline
                                      R Offline
                                      RiceBall
                                      wrote on last edited by
                                      #47

                                      @jsulm said in How to make a SVG at tab Widget ?:

                                      @RiceBall OK, no problem.
                                      The second line should print something to the console - what do you see there ("Application Output" tab in QtCreator)?

                                      Do I add code at customwidget.cpp is right ??
                                      I can't see any QDebug message.

                                      0_1560510789930_f2b4c22c-dc55-4b26-9c9b-5e85b1f1b2d9-image.png

                                      jsulmJ 1 Reply Last reply
                                      0
                                      • R RiceBall

                                        @jsulm said in How to make a SVG at tab Widget ?:

                                        @RiceBall OK, no problem.
                                        The second line should print something to the console - what do you see there ("Application Output" tab in QtCreator)?

                                        Do I add code at customwidget.cpp is right ??
                                        I can't see any QDebug message.

                                        0_1560510789930_f2b4c22c-dc55-4b26-9c9b-5e85b1f1b2d9-image.png

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

                                        @RiceBall Are you sure you create an instance of customwidget? Because I don't see the output of qDebug().

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

                                        R 1 Reply Last reply
                                        0
                                        • jsulmJ jsulm

                                          @RiceBall Are you sure you create an instance of customwidget? Because I don't see the output of qDebug().

                                          R Offline
                                          R Offline
                                          RiceBall
                                          wrote on last edited by
                                          #49

                                          @jsulm said in How to make a SVG at tab Widget ?:

                                          @RiceBall Are you sure you create an instance of customwidget? Because I don't see the output of qDebug().

                                          I have made it as you see picture.
                                          But I think it maybe somewhere is mistake.
                                          below is my file.
                                          If you have time,could you help me to check it ??
                                          link text

                                          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