I confess to beign a Qt novice and rusty on C++.
I've used QtDesigner4.6 on Ubuntu (works very well) to start developing a simple app for the N900. I designed a tabbed UI in a mainwindow widget and successfully built it with the default code (used new project -> Qt Designer form). This runs fine.
Now I want to start developing the logic behind the UI. The Ui_Form.h contains all the required widgets along with the connect statements to join the slots/signals I created in the designer.
The UI is instantiated in a file mainwindow.cpp.
My question is how I can access the ui widgets from another file for instance to create additional signals/slots between the ui widgets and to set values and so on. In the mainwindow.cpp file accessing member functions can be done by dereferencing the pointer to the ui object.
How do you add/connect additional signals/slots?
How do I access the ui widgets in another cpp file? For instance I have a QButton which on click I want to call a function (in file DOF_Calculation.cpp) and then update a QLCDNumber widget in the UI.
In mainwindow.cpp I have...
MainWindow::MainWindow( QWidget *parent):
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
.....
which is the original boiler plate code.
One option is to add the slots/signals and functions I need into the ui-form.h class definition and modify MainWindow.cpp to use them. This means any UI changes in designer will overwrite my additions.
I've tried using the template "void on_<widget name>_<signal name>(<signal parameters>);" in my DOF-calculation.h file but don't know what class to attach this too to capture the QButton click(). The DOF_functions class is defined as
class DOF_functions : public QWidget, private Ui_MainWindow { QObject ....
There must be some obvious way of a) accessing the instantiated ui components outside the scope of MainWindow.cpp and b) adding more action handing code for the ui widgets again in another class or file.
Any ideas on how???
BR David

Reply With Quote
n_CalculateDOFButton_click(void) doesn't seem tied to click event but maybe I need to call connect by name.


