Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. French
  4. Comment placer deux graphique qchart dans une même fenetre
Forum Updated to NodeBB v4.3 + New Features

Comment placer deux graphique qchart dans une même fenetre

Scheduled Pinned Locked Moved Unsolved French
7 Posts 3 Posters 1.2k 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.
  • A Offline
    A Offline
    Abdoul
    wrote on last edited by Abdoul
    #1

    Bonjour, j'aimerais savoir quel moyen , il faut utiliser pour afficher deux graphiques qchart sur la même fenêtre comme l'image suivante
    alt text

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Bonjour et bienvenu sur devnet,

      Cela est réalisable en utilisant des layouts.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      1
      • SGaistS SGaist

        Bonjour et bienvenu sur devnet,

        Cela est réalisable en utilisant des layouts.

        A Offline
        A Offline
        Abdoul
        wrote on last edited by
        #3

        @SGaist : Ok, Merci beaucoup. Est ce que vous avez un exemple de code concernant cela? J'ai essayer mais les courbes se superposent à chaque fois.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Avez-vous créé un widget par courbe ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          A 1 Reply Last reply
          1
          • SGaistS SGaist

            Avez-vous créé un widget par courbe ?

            A Offline
            A Offline
            Abdoul
            wrote on last edited by Abdoul
            #5

            'j'ai créé deux graphiques qchart auxquels j'ai lie chacun avec un qchartview. Ensuite, j'ai créé un QGridLayout dans lequel j'ai ajouté les deux qchartview et quand j'exécute, les deux courbes se superposent. Il faut noter que j'ai placé le premier qchartview à l'emplacement (0,0) et le deuxième à l'emplacement (0,11). Chaque qchartview occupe 10 lignes et 10 colonnes.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Il faut montrer le code utilisé sinon ce sera du debugging à la boule de crystal.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • C Offline
                C Offline
                cromag
                wrote on last edited by
                #7

                Voici un petit demo.

                Capture01.PNG

                mainwindow.h

                #ifndef MAINWINDOW_H
                #define MAINWINDOW_H
                
                #include <QMainWindow>
                #include <QChart>>
                
                QT_BEGIN_NAMESPACE
                namespace Ui { class MainWindow; }
                QT_END_NAMESPACE
                
                class MainWindow : public QMainWindow
                {
                    Q_OBJECT
                
                public:
                    MainWindow(QWidget *parent = nullptr);
                    ~MainWindow();
                
                private:
                    Ui::MainWindow *ui;
                
                    QtCharts::QChart chart1;
                    QtCharts::QChart chart2;
                };
                
                #endif // MAINWINDOW_H
                

                mainwindow.cpp

                #include "mainwindow.h"
                #include "ui_mainwindow.h"
                
                #include <QBarSet>
                #include <QBarSeries>
                #include <QChartView>
                #include <QLineSeries>
                
                MainWindow::MainWindow(QWidget *parent)
                    : QMainWindow(parent)
                    , ui(new Ui::MainWindow)
                {
                    ui->setupUi(this);
                
                    auto* barset1 = new QtCharts::QBarSet("Bar1", this);
                    barset1->append({4, 5, 1, 8, 7, 2, 3, 6, 9});
                
                    auto* barseries1 = new QtCharts::QBarSeries(this);
                    barseries1->append(barset1);
                
                    chart1.addSeries(barseries1);
                
                    auto* chartview1 = new QtCharts::QChartView(&chart1, this);
                    ui->verticalLayout->addWidget(chartview1);
                
                
                    auto* barset2 = new QtCharts::QBarSet("Bar2", this);
                    barset2->append({7, 2, 3, 5});
                
                    auto* barseries2 = new QtCharts::QBarSeries(this);
                    barseries2->append(barset2);
                
                    chart2.addSeries(barseries2);
                
                    auto* chartview2 = new QtCharts::QChartView(&chart2, this);
                    ui->verticalLayout_2->addWidget(chartview2);
                }
                
                MainWindow::~MainWindow()
                {
                    delete ui;
                }
                

                mainwindow.ui

                <?xml version="1.0" encoding="UTF-8"?>
                <ui version="4.0">
                 <class>MainWindow</class>
                 <widget class="QMainWindow" name="MainWindow">
                  <property name="geometry">
                   <rect>
                    <x>0</x>
                    <y>0</y>
                    <width>800</width>
                    <height>600</height>
                   </rect>
                  </property>
                  <property name="windowTitle">
                   <string>MainWindow</string>
                  </property>
                  <widget class="QWidget" name="centralwidget">
                   <layout class="QHBoxLayout" name="horizontalLayout">
                    <item>
                     <layout class="QVBoxLayout" name="verticalLayout"/>
                    </item>
                    <item>
                     <layout class="QVBoxLayout" name="verticalLayout_2"/>
                    </item>
                   </layout>
                  </widget>
                 </widget>
                 <resources/>
                 <connections/>
                </ui>
                
                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