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. My custom Qt Designer widget does not change size!

My custom Qt Designer widget does not change size!

Scheduled Pinned Locked Moved Solved General and Desktop
plugindesigner
4 Posts 2 Posters 345 Views
  • 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.
  • J Offline
    J Offline
    jdent
    wrote on 17 Mar 2024, 13:10 last edited by
    #1

    Hi,

    I have a custom chart defined like this:

    QtCustomChart::QtCustomChart(QWidget *parent)
        : QWidget(parent)
    {
        series = new QLineSeries;
        series->append(0, 6);
        series->append(2, 4);
        series->append(3, 8);
        series->append(7, 4);
        series->append(10, 5);
    
        chart = new QChart();
        chart->legend()->hide();
        chart->addSeries(series);
        chart->createDefaultAxes();
        chart->setTitle("Simple Line Chart");
    
        chart_view = new QChartView{ chart, this};
        auto rec = chart_view->geometry();
    
        auto r = this->geometry();
    
        chart_view->setGeometry(r);
    }
    

    The icon is visible in Qt Designer so the plugin is ok. However when I resize the chart in the target ui, it does not resize the chart!!

    How do I make the plugin to grow and shrink?

    Regards,
    Juan

    J C 2 Replies Last reply 17 Mar 2024, 13:55
    0
    • J jdent
      17 Mar 2024, 13:55

      @jdent I implemented resizeEvent like this:

      QtCustomChart::QtCustomChart(QWidget *parent)
          : QWidget(parent)
      {
          series = new QLineSeries;
          series->append(0, 6);
          series->append(2, 4);
          series->append(3, 8);
          series->append(7, 4);
          series->append(10, 5);
      
          chart = new QChart();
          chart->legend()->hide();
          chart->addSeries(series);
          chart->createDefaultAxes();
          chart->setTitle("Simple Line Chart");
      
          chart_view = new QChartView{ chart, this};
          auto rec = chart_view->geometry();
      
          rect = this->geometry();
          chart_view->setGeometry(rect);
      }
      
      // the event:
      
      void QtCustomChart::resizeEvent(QResizeEvent* event)
      {
          auto r = this->geometry();
          if (r.height() < rect.height() || r.width() < rect.height())
          {
              chart_view->setGeometry(rect);
          }
      	QWidget::resizeEvent(event);
      }
      

      but it is not changing the size of the chart!!

      J Offline
      J Offline
      jdent
      wrote on 17 Mar 2024, 14:12 last edited by
      #3

      @jdent I have the answer!!
      I changed the implementation of the resizeEvent:

      void QtCustomChart::resizeEvent(QResizeEvent* event)
      {
          chart_view->resize(event->size());
      	QWidget::resizeEvent(event);
      }
      

      and now it works!!

      1 Reply Last reply
      0
      • J jdent
        17 Mar 2024, 13:10

        Hi,

        I have a custom chart defined like this:

        QtCustomChart::QtCustomChart(QWidget *parent)
            : QWidget(parent)
        {
            series = new QLineSeries;
            series->append(0, 6);
            series->append(2, 4);
            series->append(3, 8);
            series->append(7, 4);
            series->append(10, 5);
        
            chart = new QChart();
            chart->legend()->hide();
            chart->addSeries(series);
            chart->createDefaultAxes();
            chart->setTitle("Simple Line Chart");
        
            chart_view = new QChartView{ chart, this};
            auto rec = chart_view->geometry();
        
            auto r = this->geometry();
        
            chart_view->setGeometry(r);
        }
        

        The icon is visible in Qt Designer so the plugin is ok. However when I resize the chart in the target ui, it does not resize the chart!!

        How do I make the plugin to grow and shrink?

        Regards,
        Juan

        J Offline
        J Offline
        jdent
        wrote on 17 Mar 2024, 13:55 last edited by
        #2

        @jdent I implemented resizeEvent like this:

        QtCustomChart::QtCustomChart(QWidget *parent)
            : QWidget(parent)
        {
            series = new QLineSeries;
            series->append(0, 6);
            series->append(2, 4);
            series->append(3, 8);
            series->append(7, 4);
            series->append(10, 5);
        
            chart = new QChart();
            chart->legend()->hide();
            chart->addSeries(series);
            chart->createDefaultAxes();
            chart->setTitle("Simple Line Chart");
        
            chart_view = new QChartView{ chart, this};
            auto rec = chart_view->geometry();
        
            rect = this->geometry();
            chart_view->setGeometry(rect);
        }
        
        // the event:
        
        void QtCustomChart::resizeEvent(QResizeEvent* event)
        {
            auto r = this->geometry();
            if (r.height() < rect.height() || r.width() < rect.height())
            {
                chart_view->setGeometry(rect);
            }
        	QWidget::resizeEvent(event);
        }
        

        but it is not changing the size of the chart!!

        J 1 Reply Last reply 17 Mar 2024, 14:12
        0
        • J jdent
          17 Mar 2024, 13:55

          @jdent I implemented resizeEvent like this:

          QtCustomChart::QtCustomChart(QWidget *parent)
              : QWidget(parent)
          {
              series = new QLineSeries;
              series->append(0, 6);
              series->append(2, 4);
              series->append(3, 8);
              series->append(7, 4);
              series->append(10, 5);
          
              chart = new QChart();
              chart->legend()->hide();
              chart->addSeries(series);
              chart->createDefaultAxes();
              chart->setTitle("Simple Line Chart");
          
              chart_view = new QChartView{ chart, this};
              auto rec = chart_view->geometry();
          
              rect = this->geometry();
              chart_view->setGeometry(rect);
          }
          
          // the event:
          
          void QtCustomChart::resizeEvent(QResizeEvent* event)
          {
              auto r = this->geometry();
              if (r.height() < rect.height() || r.width() < rect.height())
              {
                  chart_view->setGeometry(rect);
              }
          	QWidget::resizeEvent(event);
          }
          

          but it is not changing the size of the chart!!

          J Offline
          J Offline
          jdent
          wrote on 17 Mar 2024, 14:12 last edited by
          #3

          @jdent I have the answer!!
          I changed the implementation of the resizeEvent:

          void QtCustomChart::resizeEvent(QResizeEvent* event)
          {
              chart_view->resize(event->size());
          	QWidget::resizeEvent(event);
          }
          

          and now it works!!

          1 Reply Last reply
          0
          • J jdent has marked this topic as solved on 17 Mar 2024, 14:13
          • J jdent
            17 Mar 2024, 13:10

            Hi,

            I have a custom chart defined like this:

            QtCustomChart::QtCustomChart(QWidget *parent)
                : QWidget(parent)
            {
                series = new QLineSeries;
                series->append(0, 6);
                series->append(2, 4);
                series->append(3, 8);
                series->append(7, 4);
                series->append(10, 5);
            
                chart = new QChart();
                chart->legend()->hide();
                chart->addSeries(series);
                chart->createDefaultAxes();
                chart->setTitle("Simple Line Chart");
            
                chart_view = new QChartView{ chart, this};
                auto rec = chart_view->geometry();
            
                auto r = this->geometry();
            
                chart_view->setGeometry(r);
            }
            

            The icon is visible in Qt Designer so the plugin is ok. However when I resize the chart in the target ui, it does not resize the chart!!

            How do I make the plugin to grow and shrink?

            Regards,
            Juan

            C Offline
            C Offline
            ChrisW67
            wrote on 17 Mar 2024, 23:15 last edited by
            #4

            @jdent said in My custom Qt Designer widget does not change size!:

            How do I make the plugin to grow and shrink?

            You apply a layout to the widget rather than resorting to manually dealing with the geometry of the client chart

            1 Reply Last reply
            3

            1/4

            17 Mar 2024, 13:10

            • Login

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