qml in qtwidgets application : QWidget::repaint: Recursive repaint detected



  • i'am using qml file in qtwidgets application to display double values (because with qtwidgets i don't found a widget to use for display double values). the code that i used for this is :

    SUB_WIN_ADVANCEDSTATE.cpp
    
    SUB_WIN_ADVANCEDSTATE::SUB_WIN_ADVANCEDSTATE(Mainwindow const& p) : QDockWidget(),mainwindow_ins(p)
    { 
      gauge_1 = new QObject(this);
       gauge_2 = new QObject(this);
       gauge_3 = new QObject(this);
       gauge_4 = new QObject(this);
    
       m_qmlview_gauge_1 = new QQuickView(QUrl("qrc:/Resources/res/qml/actuator_gauge.qml"));
       m_qmlview_gauge_1->setResizeMode(QQuickView::SizeRootObjectToView);
       m_qmlview_gauge_1->setColor(QColor(Qt::white));
       QWidget *container = QWidget::createWindowContainer(m_qmlview_gauge_1);
       container->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding);
       ui.verticalLayout_11->addWidget(container);
    
       m_qmlview_gauge_2 = new QQuickView(QUrl("qrc:/Resources/res/qml/actuator_gauge.qml"));
       m_qmlview_gauge_2->setResizeMode(QQuickView::SizeRootObjectToView);
       m_qmlview_gauge_2->setColor(QColor(Qt::white));
       QWidget *container_1 = QWidget::createWindowContainer(m_qmlview_gauge_2);
       container_1->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding);
       ui.verticalLayout_12->addWidget(container_1);
    
       m_qmlview_gauge_3 = new QQuickView(QUrl("qrc:/Resources/res/qml/actuator_gauge.qml"));
       m_qmlview_gauge_3->setResizeMode(QQuickView::SizeRootObjectToView);
       m_qmlview_gauge_3->setColor(QColor(Qt::white));
       QWidget *container_2 = QWidget::createWindowContainer(m_qmlview_gauge_3);
       container_2->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding);
       ui.verticalLayout_13->addWidget(container_2);
    }
    
    void SUB_WIN_ADVANCEDSTATE::get_actuator_length(QVariant l)
    {
    //------------------------- set propreties of gauge_1 ----------------------------------------------------------------
       object_gauge_1 = m_qmlview_gauge_1->rootObject();
       gauge_1 = object_gauge_1->findChild<QObject*>("gauge");
       if (gauge_1){
           gauge_1->setProperty("maximumValue", Mainwindow::G_st_infosHexa.L_max_actuator[0]);
           gauge_1->setProperty("minimumValue", Mainwindow::G_st_infosHexa.L_min_actuator[0]);
          // gauge_1->setProperty("tickmarkStepSize", Mainwindow::G_st_infosHexa.L_increment[0]);
           gauge_1->setProperty("value", convertions_array[0]);
           qDebug()<<convertions_array[0]<< Mainwindow::G_st_infosHexa.L_increment[0];
       }
       //------------------------- set propreties of gauge_2 ----------------------------------------------------------------
       object_gauge_2 = m_qmlview_gauge_2->rootObject();
       gauge_2 = object_gauge_2->findChild<QObject*>("gauge");
       if (gauge_2){
           gauge_2->setProperty("maximumValue", Mainwindow::G_st_infosHexa.L_max_actuator[1]);
           gauge_2->setProperty("minimumValue", Mainwindow::G_st_infosHexa.L_min_actuator[1]);
          // gauge_2->setProperty("tickmarkStepSize", Mainwindow::G_st_infosHexa.L_increment[1]);
           gauge_2->setProperty("value", convertions_array[1]);
           qDebug()<< Mainwindow::G_st_infosHexa.L_increment[1];
       }
       //------------------------- set propreties of gauge_3 ----------------------------------------------------------------
       object_gauge_3 = m_qmlview_gauge_3->rootObject();
       gauge_3 = object_gauge_3->findChild<QObject*>("gauge");
       if (gauge_3){
           gauge_3->setProperty("maximumValue", Mainwindow::G_st_infosHexa.L_max_actuator[2]);
           gauge_3->setProperty("minimumValue", Mainwindow::G_st_infosHexa.L_min_actuator[2]);
          // gauge_3->setProperty("tickmarkStepSize", Mainwindow::G_st_infosHexa.L_increment[2]);
           gauge_3->setProperty("value", convertions_array[2]);
           qDebug()<< Mainwindow::G_st_infosHexa.L_increment[3];
       }
    SUB_WIN_ADVANCEDSTATE::~SUB_WIN_ADVANCEDSTATE()
    {
       delete m_qmlview_gauge_1;
       delete m_qmlview_gauge_2;
       delete m_qmlview_gauge_3;
    
       delete gauge_1;
       delete gauge_2;
       delete gauge_3;
    }
    
    SUB_WIN_ADVANCEDSTATE.h
    
       QQuickView *m_qmlview_gauge_1;
       QQuickView *m_qmlview_gauge_2;
       QQuickView *m_qmlview_gauge_3;
    
       QObject *gauge_1;
       QObject *gauge_2;
       QObject *gauge_3;
       
       QObject *object_gauge_1 ;
       QObject *object_gauge_2 ;
       QObject *object_gauge_3 ;    
    

    when i run the program and i try to move qdockwidgets several times, the application crash with errors :

    QWidget::repaint: Recursive repaint detected
    In file ....\include/QtCore/../../src/corelib/global/qglobal.h, line 770: Out of memory
    Invalid parameter passed to C runtime function.
    Invalid parameter passed to C runtime function.

    0_1529505749356_30bfb0c5-9dcc-431b-9e35-03519e9ec000-image.png



  • @halima

    i'am using qml file in qtwidgets application to display double values (because with qtwidgets i don't found a widget to use for display double values).

    For the record: http://doc.qt.io/qt-5/qdoublespinbox.html
    Or just a QLabel for display-only.
    It can't be worth introducing QML just to display a number, if that's what you mean.



  • @JonB thanks for reply.

    in the specifications I have to use a graphical component to represent a length with floating values ​​like qdial or slider progress bar ...

    that's why I opt for qml :(


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.