條件:

①2個類直接沒有任何關係;

②接收訊息的類必須有一個全域性變數;

 QMetaObject::invokeMethod((QObject*)全域性變數類, "接收的方法", Qt::AutoConnection, Q_ARG(接收的引數型別, 接收的引數));

class ViewManagerA : public QMainWindow
{
    Q_OBJECT   
public:
    ViewManagerA(QWidget *parent = 0);
    ~ViewManagerA();
private slots:
    //介面點選事件處理
    void receiveMsg(QString msg);
}


ViewManager *g_viewManagerA;

extern ViewManager *g_viewManagerA;
class ViewManagerB : public QObject
{
    Q_OBJECT   
public:
    ViewManagerB(QWidget *parent = 0);
    ~ViewManagerB();
 private:
    void sendMsg();
}



 
void ViewManagerB::sendMsg()
{
   QMetaObject::invokeMethod((QObject*)g_viewManagerA, "receiveMsg", Qt::AutoConnection, Q_ARG(QString, "測試"));
}