Ui can only be referenced in mainwindow.c



  • Currently, ui can be referenced in mainwindow.c but not in other files.
    How to eliminate this shortcoming.

    @ mainwindow.c
    ui->m_label->setText("Good Morning");

    ticker.cpp
    ui->m_label_>setText("Good Morning"); //not possible.

    @



  • ui is a privet pointer in a MainWindow class.
    If you want to update a content of ui from another class then you
    need to add a signal to a ticker class and emit that signal each time when you need to update a content of MainWindow::ui or you need to pass ui to that class. In the later case you will have to maintain ui from two classes which is not very good idea.


Log in to reply
 

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