Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to correctly make the ui pointer global so that even my static functions can access it ?



  • i want to make ui pointer global , so that even my static functions can access it, This is my .h file , do i need to add something in my .cpp file as well ?

    #pragma once
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    #include "windows.h"
    #include "windowsx.h"
    
    QT_BEGIN_NAMESPACE
    namespace Ui { class MainWindow; }
    QT_END_NAMESPACE
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT                      //Used to handle events
        Q_DISABLE_COPY(MainWindow) //added
    
    public:
        MainWindow(QWidget* parent = 0);
        ~MainWindow();                    //Destructor used to free resources
    
        // Static method that will act as a callback-function
       static LRESULT CALLBACK mouseProc(int Code, WPARAM wParam, LPARAM lParam);
    
     //   BOOL InitializeUIAutomation(IUIAutomation** automation);
    
      static Ui::MainWindow* ui; // How do i make this global ??
    
    private:
    
        // hook handler
        HHOOK mouseHook;
    };
    #endif // MAINWINDOW_H
    


  • @learnist please don't double post. Issue is being discuss there.


Log in to reply