The window is a bit unclear.
First, we start with the Qt Creator wizard,
So create a project, Application, and Qt Quick Application.
Qt Quick Component Set select Qt Quick 2.0
After step by step, we can see hello world
In this way, there are several problems.
Question 1: main. cpp
#include<QtGui/QGuiApplication>
#include"qtquick2applicationviewer.h"
int main(int argc,char *argv[])
{
QGuiApplication app(argc,argv);
QtQuick2ApplicationViewer viewer;
viewer.setMainQmlFile(QStringLiteral("qml/qx/main.qml"));
viewer.showExpanded();
returnapp.exec();
}
How is this different from what we wrote in the Qt example (examples \ quick?
Question 2: This is just a simple qml window. Can I customize a window?
For example, if you do not need a border, you need to have the system's default title bar Titlebar.
For example, if you want to use the default title bar, you need to remove the maximum value.
Question 3: I want to hide my qml files and package them into exe.
These three problems are the key points of making Qt Quick's toys really a software product, of course for me.
From the requirement, I need a main window to customize the title bar. I need to package qml into exe. After referring to the example, I found the solution. Package it into exe, which is actually very simple. Create a qrc in the project and add qml to it. However, in the debugging process, it is quite troublesome to create a qrc and modify the qml one by one. Instead, it is easy to use qrc.
Window problem. The example is examples \ quick \ window. Basically, the window definition and pop-up window function have been implemented. main. cpp is also very concise. Unlike the wizard, we will add a qtwuick2applicationviewer class. Imitating this example, we will find that the root of the master qml is no longer an Item, but a Window, and an introduction of importQtQuick. Window2.1
Note that the Qt5Widgets. dll must be released along with the final release file in this way. Unfortunately, 4 M more files were released.
Let's talk about the Window. At this time, we can help you carefully view the properties and methods of the Window.
For example, remove the title bar. Or, you can only remove the maximization. These are all easy tasks.
Of course, in addition to the Window as the root mode in the example, there is also the QtObject as the root, the custom Window as the property mode, and then the corresponding Window is displayed after the Component. onCompleted signal.
This is really funny. At the beginning of a good thing, it is generally a problem that can only be solved in one way. However, at a certain stage of development, it is always confusing. It corresponds to a problem and comes up with n solutions, make the user think that @ # $ %... So I can only say that "I still have some questions that are unclear". There are still other standard methods.
I talked about a lot of methods, but I didn't mention the details. Are you disappointed?