Hello to everyone.

I'm trying to write a piece of C++/Qt code and I always seem to get stuck at the same thing.

I'm creating a DAQ System for my MSc thesis, who's purpose is to present and get some variables from the user interface (class name Interface) and when a pushbutton is clicked() to pass them to a class named DAQCycle that needs them in order to operate properly. So for example:

# interface.h
class Interface{
void doThat();

uint32_t VAR1;
int VAR2;
std::string VAR3;
std::vector<CLASSNAME*> VAR4;
class DAQCycle{...}
# DAQCycle.cpp
for(int k=0; k<Interface.VAR2; k++){
 // doSomething..

The problem is of course that I don't create (and I actually I cannot see how to create) an object of the class Interface in order to instantiate its variables that I need for my other class.

Is there any way to circumvent that?

PS. My main() is the standard Qt main function

#include <QtGui/QApplication>

#include "Interface.h"
#include "DAQCycle.h"

using namespace Ui;

int main(int argc, char *argv[])
    QApplication a(argc, argv);
    Interface w;
    return a.exec();

Thanks in advance.

Just make the handler for the click button event in the Interface class, and then call a function of the DAQCycle class, and pass it the "this" pointer of the Interface object.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.