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. Update data send from class B to class A
Forum Updated to NodeBB v4.3 + New Features

Update data send from class B to class A

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 165 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.
  • I Offline
    I Offline
    Isidro Perla
    wrote on last edited by
    #1

    Hello!, I want to send the values of the global var time from my class myopenglwidget.cpp to mainwindow.cpp, in a label called lb_ax, My var time changes values constantly, and I need to sending from myopenglwidget to mainwindow, those values in that label, here are some fragments of the most importantly part of my code:

    //mainwindow.cpp

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

    MyOpenGLWidget *a = new MyOpenGLWidget;
    
    bool result = connect(a, SIGNAL(textChanged(QString)),ui->lb_ax, SLOT(setText(QString)));
    
    qDebug()<<"conn;" <<result;
    
    a->someFunctionThatChangesText("");
    
    QApplication::processEvents();
    QWidget::repaint();
    
    update();
    

    }

    //mainWindow.h

    public:
    void UpdateLabel(const QString text);

    //myopenglwidget.cpp

    void MyOpenGLWidget::someFunctionThatChangesText(const QString& newtext){
    emit textChanged(QString::number(time));
    }

    //myopenglwidget.h

    signals:
    void textChanged(QString);
    public:
    void someFunctionThatChangesText(const QString& newtext);

    I want to know what is the problem here, because now only send the initialized value of the var, that is 0, some ideas please??

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      It's the same question as here:
      https://forum.qt.io/topic/112755/send-real-time-data-from-another-class-to-mainwindow-label/2

      Don't double post.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1

      • Login

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