Solved scope problems
-
I am trying to call library functions from within the Qwidget application.
it looks something like this:
SysManager myMgr;
IPort *iPort;
SysManager::FindComHubPorts(comHubPorts);
myMgr.ComHubPort(0, "/dev/ttyXRUSB0");
myMgr.PortsOpen(1);
IPort &myPort = myMgr.Ports(0);
INode &theNode = myPort.Nodes(0);followed by:
theNode.Status.RT.Refresh();It would be desirable to be able to call the "theNode.Status.RT.Refresh();" from a Qt button or from within some other function other than QMainwindow. I tried putting SysManager myMgr; before the QMainWindow constructor, but I get "error, not declared in this scope". What then is the correct way to call the member functions of the library from a button in Qt? I can provide complete code if that would help clarify. Thanks
-
@CharlesHuff Not sure where this code is actually located.
But why don't you putSysManager myMgr;
as class member in your MainWindow class?
-
I googled "add a class member to your QMainWindow"...
assuming I can figure out the proper syntax, are you saying that putting:
SysManager myMgr; inside the QMainWindow function will make theNode.Status.RT.Refresh(); available inside of the void on_click_button function that is outside of QMainWindow? I put everything before the "followed by:" above in the QMainWindow function and it worked only inside of QMainWindow, not within the button's on_click function...My desire is to setup the variables of the library inside QMainWindow and then later manipulate them from button presses...
I know you answer is very likely correct, I just don't know how to do that...
-
Hi,
See the c++ classes tutorial.
-
putting " SysManager myMgr; " into each function that calls theNode.Status.RT.Refresh(); works! I am also amazed that Qt seems to somehow 'know' all the member function names now...
I am starting to like c++ more every day!
Thanks
-
Qt is just C++. Creating a SysManager object in each function might not be the best idea. Having one instance in your class will make you code cleaner. Note that this doesn't apply to every situation.