14 Ocak 2019 Pazartesi

Emit Signal from static function

class MainWindow : public QMainWindow
{
    ...
    private:
        static MainWindow* m_psMainWindow;

        void emit_signal_TrameRecu(StructureSupervision::T_StructureSupervision* ptr)
        {
            emit signal_TrameRecup(ptr);
        }
};

// Implementation

// init static ptr
MainWindow* MainWindow::m_psMainWindow = nullptr; // C++ 11 nullptr

MainWindow::MainWindow(QWidget* parent)
    : QMainWindow(parent)
{
    m_psMainWindow = this;
}


void MainWindow::lancerServeur(std::atomic& boolServer)
{
    StructureSupervision::T_StructureSupervision* bufferStructureRecu;

    ...

    if(m_psMainWindow)
        m_psMainWindow->emit_signal_TrameRecu( bufferStructureRecu );
}
Share: