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. Updating a Q3DScatter by PushButton
Qt 6.11 is out! See what's new in the release blog

Updating a Q3DScatter by PushButton

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 919 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.
  • T Offline
    T Offline
    Timo_F
    wrote on last edited by
    #1

    Hello everybody,

    I'm new in Qt and I want to use a Q3DScatter for visualizing points.
    I embedded the Q3DScatter in a QWidget and the QWidget in a gridLayout.
    The code is shown below. It's just the Scatter without data.

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    Q3DScatter *graph = new Q3DScatter();

    QWidget *container = QWidget::createWindowContainer(graph);
    
    Q3DScatter *graph2 = new Q3DScatter();
    
    QWidget *container2 = QWidget::createWindowContainer(graph2);
    

    ui->gridLayout->addWidget(container);
    ui->gridLayout_2->addWidget(container2);
    }

    In the next step I want to use a PushButton for updating the points. The method looks like this:

    void MainWindow::on_pushButton_4_clicked()
    {
    scattermodifier *modifier = new scattermodifier(graph);

    scattermodifier *modifier_2 = new scattermodifier(graph2);

    }

    Basicly, the scattermodifier works but how can I use graph and graph2 from the MainWindow class?
    I guess it's a C++ topic but maybe anybody could give me a hint how to solve this problem :-)

    Thanks a lot.

    Kindly regards,

    Timo

    jsulmJ 1 Reply Last reply
    0
    • T Timo_F

      Hello everybody,

      I'm new in Qt and I want to use a Q3DScatter for visualizing points.
      I embedded the Q3DScatter in a QWidget and the QWidget in a gridLayout.
      The code is shown below. It's just the Scatter without data.

      MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
      {
      ui->setupUi(this);

      Q3DScatter *graph = new Q3DScatter();

      QWidget *container = QWidget::createWindowContainer(graph);
      
      Q3DScatter *graph2 = new Q3DScatter();
      
      QWidget *container2 = QWidget::createWindowContainer(graph2);
      

      ui->gridLayout->addWidget(container);
      ui->gridLayout_2->addWidget(container2);
      }

      In the next step I want to use a PushButton for updating the points. The method looks like this:

      void MainWindow::on_pushButton_4_clicked()
      {
      scattermodifier *modifier = new scattermodifier(graph);

      scattermodifier *modifier_2 = new scattermodifier(graph2);

      }

      Basicly, the scattermodifier works but how can I use graph and graph2 from the MainWindow class?
      I guess it's a C++ topic but maybe anybody could give me a hint how to solve this problem :-)

      Thanks a lot.

      Kindly regards,

      Timo

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

      @Timo_F I don't understand the problem: graph and graph2 are already created in MainWindow. The only thing you need to change is: make them class member:

      class MainWindow
      {
      private:
          Q3DScatter *graph;
          Q3DScatter *graph2;
      ...
      };
      
      MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
      {
      ui->setupUi(this);
      
      graph = new Q3DScatter();
      
      QWidget *container = QWidget::createWindowContainer(graph);
      
      graph2 = new Q3DScatter();
      
      QWidget *container2 = QWidget::createWindowContainer(graph2);
      
      ui->gridLayout->addWidget(container);
      ui->gridLayout_2->addWidget(container2);
      }

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

      1 Reply Last reply
      1
      • T Offline
        T Offline
        Timo_F
        wrote on last edited by
        #3

        Thanks, it works ^^.

        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