I'm learning QT, QT5. When I start the Qt Creator and prepare a project with all the default settings, I get these 2 files, (I'm leaving the main CPP and .pro files) mainwindow.h mainwindow.cpp Now, I like to do it like this, My_mainwindow.h my_mainwindow.cpp The main differences between the code of my code and the QT creator are: My question is whether there is no harm to using my approach or is there any use of it? Qt is using the manufacturer's approach? Please give a detailed answer.
#ifndef MAINWINDOW_H # defined MAINWINDOW_H # included & lt; QMainWindow & gt; Namespace UI {Class MainWindow; } Class Main Window: Public QMainWindow {Q_OBJECT Public: Clear Men Window (QWidget * parent = 0); ~ MainWindow (); Private: UI :: MainWondo * UI; }; #endif // MAINWINDOW_H
code = #include "mainwindow.h" #include "ui_mainwindow .h "MainWindows :: Men Wando (Quedgate * Parent): Q Menine (UI) (New UI: Main Wando) (UI-> Setup UI (this);} Main Window :: ~ MAIN WANDO
#ifndef MAINWINDOW_H # include MAINWINDOW_H # include & lt; QMainWindow & gt; #include "ui_mainwindow.h" class MainWindow: public QMainWindow, Private Ui_MainWindow {Q_OBJECT Public: Clear MainWindow (QWidget * parent = 0);}; #endif // MAINWINDOW_H
Nameshot Yue no. (Can someone explain me the use of this namespace here?)
MainWindow class both
QMainWindow and
Ui_MainWindow > While the code of Qt Creator gets it from the
QMainWindow class only.
#include "ui_mainwindow.h" , and in return, many coolouts like
& lt; QLabel & gt; ,
& lt; QPushButton & gt; etc. This reduces compilation speed significantly, which includes
mainwindow.h , all of which include those QtWidgets when Ui class is used as a member And it is forwarded, then in all these, only need to be compiled when compiling
mainwindow.cpp , but since
mainwindow.h does not include Goes somewhere else
No comments:
Post a Comment