PDA

View Full Version : accessing .ui file from another C file



nackasha
27th July 2011, 18:33
Hello Folks,

I have a question:

I have created a project in Qt, and created a gui.

so now i have the following:
headers:
mainwindow.h
myfunction.h

sources:
mainwindow.cpp
myfunction.cpp

forms:
mainwindow.ui


In my mainwindow.cpp, i call the function myfunction.cpp. And everything is fine and does what is suppose to do.

My question is:
I want to control and update some Qlabels in mainwindow.h, how can i do that ? I know i can control the GUI through mainwindow.cpp but can i do some updates through myfunction.cpp ?


Please kindly advice,

Talei
27th July 2011, 21:00
Use signal/slot mechanism or getter/setter approach.

squidge
27th July 2011, 23:25
Agreed. The GUI management should be restricted to a single class whenever possible. If you want another class to be able to update/read the GUI then send the appropriate data to/from the GUI management class using appropriate member functions.