This is a very newbie question
It' a basic problem of scope between objects.
In attachment the full example code.
I have the main object (qt4testMainWindow : public QMainWindow) and I have a secondary object (qt4testData: public QObject) created by the first one.
The main object build a UI of QMainWindow type; the second handle data but have to comunicate with the main object: it must call a main object's method.
So I've created the new secondary object passing it the reference to the main UI (see "main_window.cpp" file at line 30).
It's all ok if I have to change a UI value (see "qt4test_data.cpp" at line 30) from inside the secondary object.
My problem is: how can I invoke "qt4testMainWindow::changeVar" method from the
secondary object?
I tried the method you can see in "qt4test_data.cpp" at line 32 without success:
main_ui->changeVar ( 20 );
main_ui->changeVar ( 20 );
To copy to clipboard, switch view to plain text mode
but I have a compiler error:
qt4test_data.cpp: In member function ‘void qt4testData::init()’:
qt4test_data.cpp:32: error: base operand of ‘->’ has non-pointer type ‘Ui::MainWindow’
qt4test_data.cpp: In member function ‘void qt4testData::init()’:
qt4test_data.cpp:32: error: base operand of ‘->’ has non-pointer type ‘Ui::MainWindow’
To copy to clipboard, switch view to plain text mode
Any help?
Thanks,
the_bis
Bookmarks