[SOLVED] QMainWindow::QMainWindow: cannot access private member...
-
Hi folks, I have this time a new problem with this code:
@
class MainWindow : public QMainWindow
{
Q_OBJECTpublic: MainWindow(Qt::WindowFlags f = 0);
}; // <== Here, I get the problem.
@This code is working, because it is in DLL and it successfully compile it. But, when I try to compile an App which uses this code it says:
bq. C:\Projects\Project\MainWindow.h:17: error: C2248: 'QMainWindow::QMainWindow' : cannot access private member declared in class 'QMainWindow'
-
There was just encapsulation into namespaces.
Well, I am not able to copy that object with operator =... I had in code:
@
extern "C" {DLL_EXPORT MainWindow exportMainWindow()
{
return MainWindow(0,0);
}
@And in Application was code:
@
typedef MainWindow (*MainWindowHandler) ();
MainWindowHandler mainWindow = (MainWindowHandler) lib->resolve("exportMainWindow");MainWindow mW = mainWindow(); // <= copying object is not acceptable.
// 'operator =' and Constructor() are private...
@ -
[[Doc:QObject]]s canot be passed as value types, but only as pointers:
@
MainWindow* exportMainWindow()
{
return new MainWindow(0);
}
@But be aware that you need to delete the object eventually, and - much more important - that you may run into memory management issues on Windows, especially when mixing C and C++ code across library boundaries. Watch out!