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 I can connect circularGauge qml with signal in cpp
QtWS25 Last Chance

How I can connect circularGauge qml with signal in cpp

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 302 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    my code in QML:

    import QtQuick 2.6
    import QtQuick.Controls 2.1
    import QtQuick.Extras 1.4
    import QtQuick.Controls.Styles 1.4
    
    Rectangle{
    
        width:300
        height: 300
        //property alias CircularGauge:circularGauge
        function setvalue(value){ circularGauge.value = value; }
    
    
    
      CircularGauge{
    
          id: circularGauge
          anchors.centerIn: parent
                 minimumValue : -30
                 maximumValue : 30
                 style: CircularGaugeStyle
                 {
                     minimumValueAngle : -90
                     maximumValueAngle  : 90
    
                     needle:Item
                     {
         //                Rectangle
         //                {
         //                    width: outerRadius * 0.02
         //                    height: outerRadius * 0.7
         //                    color: "Light Blue"
         //                }
                     }
                     foreground: Item
                     {
         //                Rectangle {
         //                    width: outerRadius * 0.2
         //                    height: width
         //                    radius: width / 2
         //                    color: "#e5e5e5"
         //                    anchors.centerIn: parent
         //                }
                     }
    
                     tickmarkLabel:Text
                     {
                         color:"Black"
                         text : styleData.value
                     }
                 }
             }
    
    
    
    
    
      }
    
    
    
    
    
    //MY CODE IN mainWindow cpp:
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QtQml>
    
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
        ui->qml->setSource(QUrl("qrc:///uil.qml"));
        ui->qml->show();
       
        auto rootObject = ui->qml->rootObject();
        connect(this,SIGNAL(setGauge(QVariant)),rootObject,SLOT(setvalue(QVariant)));
    
    
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::on_dial_sliderMoved(int position)
    {
        emit setGauge(15.5);
    }
    
    
    
    
    

    15.5 is an example of a number..Can you help me?

    ? 1 Reply Last reply
    0
    • ? A Former User

      my code in QML:

      import QtQuick 2.6
      import QtQuick.Controls 2.1
      import QtQuick.Extras 1.4
      import QtQuick.Controls.Styles 1.4
      
      Rectangle{
      
          width:300
          height: 300
          //property alias CircularGauge:circularGauge
          function setvalue(value){ circularGauge.value = value; }
      
      
      
        CircularGauge{
      
            id: circularGauge
            anchors.centerIn: parent
                   minimumValue : -30
                   maximumValue : 30
                   style: CircularGaugeStyle
                   {
                       minimumValueAngle : -90
                       maximumValueAngle  : 90
      
                       needle:Item
                       {
           //                Rectangle
           //                {
           //                    width: outerRadius * 0.02
           //                    height: outerRadius * 0.7
           //                    color: "Light Blue"
           //                }
                       }
                       foreground: Item
                       {
           //                Rectangle {
           //                    width: outerRadius * 0.2
           //                    height: width
           //                    radius: width / 2
           //                    color: "#e5e5e5"
           //                    anchors.centerIn: parent
           //                }
                       }
      
                       tickmarkLabel:Text
                       {
                           color:"Black"
                           text : styleData.value
                       }
                   }
               }
      
      
      
      
      
        }
      
      
      
      
      
      //MY CODE IN mainWindow cpp:
      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      #include <QtQml>
      
      
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      
          ui->qml->setSource(QUrl("qrc:///uil.qml"));
          ui->qml->show();
         
          auto rootObject = ui->qml->rootObject();
          connect(this,SIGNAL(setGauge(QVariant)),rootObject,SLOT(setvalue(QVariant)));
      
      
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      
      void MainWindow::on_dial_sliderMoved(int position)
      {
          emit setGauge(15.5);
      }
      
      
      
      
      

      15.5 is an example of a number..Can you help me?

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      @vale88 I solved

      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