Home > Mobile >  Qt in call class method through plug-ins to undefined reference problem
Qt in call class method through plug-ins to undefined reference problem

Time:11-05

I will be a QWidget class encapsulates Qplugin, the mainWindow calls in the main program, the entire file structure is as follows:
1. The custom class

* * Mwidget. H * * *

The class Mwidget: public QWidget
{
Public:
Structure, destructors, etc...
Void the open ();
}
* * Mwidget. CPP * *

Implementation:
Void Mwidget: : open () {}

2. The interface class: MwidgetInterface

* * MwidgetInterface. H * * *
` ` `
H # include Mwidget.
Mwidget * getMwidget ();
` ` `
3. The plug-in class

` ` `
H # include MwidgetInterface.
Mwidget * getMwidget ();
` ` `
4. In actual use in mainwindow
Mainwindow. H
` ` `
H # include MwidgetInterface.
` ` `
Mwidget were obtained through the plug-in class, because in the main window of the header file mainwindow. Introduces the plugin to h header file MwidgetInterface. J h, and plug-in header file introduces Mwidget. H, so Mwidget in the mainwindow calls the open method, can be introduced in QtCreator, but shown in compile
` ` `
Error: undefined reference to ` Mwidget: : open () ',
` ` `
This is what reason, should how to fix it?

CodePudding user response:

Hens, you should be on Qt section
  •  Tags:  
  • Qt
  • Related