Hello , I am really new in C++ development .
I am working on Qt Application .
I need to call a member class in another class without creating an instance .
Can I do this ?
thank you
There is no such thing as "calling a class". If you mean calling a member function within a class that is defined within another class, okay, but if you want to do it "without creating an instance" then the member function must be static.
If the other class has a function that returns a MainWindow reference (MainWindow&), sure.
Maybe if you explained what the other object is, how it contains or references a MainWindow object, and what you want to do with this object, we would be better able to help you.
@doug4
Currently I haven't class which return a reference .
what i have actually :
In Mainwindow :
1/ I have a quickwidget which integrate a qml file .
2/ I create a backend instance to get data from it and fill the QMl File
=> So in MainWindow I have a Backend instance
In Backend
1/I have the definition of my data (getter, setter, change slots).
In UploadCSV
1/I have a button when it's clicked a slot in Backend will change some data .
2/After change data I would like to display it on QML .
=> And in UploadCSV I have another Backend instance
=> the problem is when i create 2 instance I can't get data changed .(and it's logic)
this UploadCSV code:
1 2
Backend *back = new Backend(); // this line cause problem
connect(ui->parambtn_2, SIGNAL(clicked()),back , SLOT(status()),Qt::QueuedConnection); I must replace back by th instance created in Mainwindow