Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. Wofür der Macro "QT_BEGIN_NAMESPACE"
Forum Updated to NodeBB v4.3 + New Features

Wofür der Macro "QT_BEGIN_NAMESPACE"

Scheduled Pinned Locked Moved Solved German
4 Posts 3 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Galilio
    wrote on last edited by
    #1

    Hallo Zusammen,

    bei Qt5 ist mir aufgefallen die Benutzung von dieses Macro QT_BEGIN_NAMESPACE.
    z.b:

    QT_BEGIN_NAMESPACE
    class QAction;
    class QCheckBox;
    class QComboBox;
    class QGroupBox;
    class QLabel;
    class QLineEdit;
    class QMenu;
    class QPushButton;
    class QSpinBox;
    class QTextEdit;
    QT_END_NAMESPACE
    
    //! [0]
    class Window : public QDialog
    {
        Q_OBJECT
    
    public:
        Window();
    
        void setVisible(bool visible) Q_DECL_OVERRIDE;
    
    protected:
        void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
    
    private slots:
        void setIcon(int index);
        void iconActivated(QSystemTrayIcon::ActivationReason reason);
        void showMessage();
        void messageClicked();
    
    private:
        void createIconGroupBox();
        void createMessageGroupBox();
        void createActions();
        void createTrayIcon();
    
        QGroupBox *iconGroupBox;
        QLabel *iconLabel;
        QComboBox *iconComboBox;
        QCheckBox *showIconCheckBox;
    
        QGroupBox *messageGroupBox;
        QLabel *typeLabel;
        QLabel *durationLabel;
        QLabel *durationWarningLabel;
        QLabel *titleLabel;
        QLabel *bodyLabel;
        QComboBox *typeComboBox;
        QSpinBox *durationSpinBox;
        QLineEdit *titleEdit;
        QTextEdit *bodyEdit;
        QPushButton *showMessageButton;
    
        QAction *minimizeAction;
        QAction *maximizeAction;
        QAction *restoreAction;
        QAction *quitAction;
    
        QSystemTrayIcon *trayIcon;
        QMenu *trayIconMenu;
    };
    

    Wie wichtig ist dieses Macro?

    Danke

    aha_1980A 1 Reply Last reply
    0
    • Paul ColbyP Offline
      Paul ColbyP Offline
      Paul Colby
      wrote on last edited by
      #2

      This QT_BEGIN_NAMESPACE macro is used to wrap Qt classes in the (optional) QT_NAMESPACE namespace. The Qt libraries that ship pre-compiled from the Qt website, as well as those in most OS distributions are built without any wrapping namespace (ie QT_NAMESPACE is empty, and QT_BEGIN_NAMESPACE does nothing). However, in some circumstances, you wish to rebuild Qt from source, with QT_NAMESPACE defined. Unless you (or someone else) rebuilds Qt from source, it's unlikely you'll ever need it.

      Of course, if you were creating code intended to be included in the Qt project, you would be required to use those the QT_BEGIN_NAMESPACE and QT_END_NAMESPACE macros to allow users to QT_NAMESPACE if they wish.

      See also:

      • https://wiki.qt.io/Qt_In_Namespace
      • https://stackoverflow.com/questions/3341350/is-it-important-to-declare-the-namespace-with-qt-begin-namespace-qt-end-names

      Cheers.

      1 Reply Last reply
      3
      • G Galilio

        Hallo Zusammen,

        bei Qt5 ist mir aufgefallen die Benutzung von dieses Macro QT_BEGIN_NAMESPACE.
        z.b:

        QT_BEGIN_NAMESPACE
        class QAction;
        class QCheckBox;
        class QComboBox;
        class QGroupBox;
        class QLabel;
        class QLineEdit;
        class QMenu;
        class QPushButton;
        class QSpinBox;
        class QTextEdit;
        QT_END_NAMESPACE
        
        //! [0]
        class Window : public QDialog
        {
            Q_OBJECT
        
        public:
            Window();
        
            void setVisible(bool visible) Q_DECL_OVERRIDE;
        
        protected:
            void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
        
        private slots:
            void setIcon(int index);
            void iconActivated(QSystemTrayIcon::ActivationReason reason);
            void showMessage();
            void messageClicked();
        
        private:
            void createIconGroupBox();
            void createMessageGroupBox();
            void createActions();
            void createTrayIcon();
        
            QGroupBox *iconGroupBox;
            QLabel *iconLabel;
            QComboBox *iconComboBox;
            QCheckBox *showIconCheckBox;
        
            QGroupBox *messageGroupBox;
            QLabel *typeLabel;
            QLabel *durationLabel;
            QLabel *durationWarningLabel;
            QLabel *titleLabel;
            QLabel *bodyLabel;
            QComboBox *typeComboBox;
            QSpinBox *durationSpinBox;
            QLineEdit *titleEdit;
            QTextEdit *bodyEdit;
            QPushButton *showMessageButton;
        
            QAction *minimizeAction;
            QAction *maximizeAction;
            QAction *restoreAction;
            QAction *quitAction;
        
            QSystemTrayIcon *trayIcon;
            QMenu *trayIconMenu;
        };
        

        Wie wichtig ist dieses Macro?

        Danke

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Galilio Wie @Paul-Colby richtig gesagt hat, ist dieses Makro interessant, wenn du forward-Deklarationen zu Qt-Klassen benutzt und Qt in einem namespace compiliert hast.

        Wenn du deinen Quelltext an andere weitergibst, haben die damit max. Freiheit z.B. mehrere Qt-Versionen (in plugins oder DLLs) zu mischen.

        Qt has to stay free or it will die.

        1 Reply Last reply
        2
        • G Offline
          G Offline
          Galilio
          wrote on last edited by
          #4

          @aha_1980 und @Paul-Colby
          Danke

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved