Explorer and icon settings steps
- qrc is responsible for loading some resource files, which can be seen when the project is newly created
2. qrc is responsible for loading icon resources, etc. Because the path contains Chinese, it often cannot be set automatically, and needs to be added manually. The order of adding is: (1) Open the resource management file.qrc (2) Copy the qrc file of the
current
project Add it in (equivalent to VS having a qrc file, but because the path may contain Chinese, you need to manually add the resource file yourself) (
3) Select the original resource file in the project (this step can also be manually filled in the qrc edit column Enter QtMainWindow.qrc) (4) Create a new icon folder in the project folder, and put in png, ico and other types of icons in advance; (
5) Add add files in the qrc file, here is to add the icon folder (if there is no previous step, you cannot add Add Files here)
(6) Add all the picture files of the icon in the project folder prepared in advance.
So far,
after the addition is complete, open the ui, enter the ui editing interface, open the resource manager, and you can see that the icon file is already included
property editor
After dragging in a control, for example here, dragging in a Label control, you can see the inheritance relationship between classes from the property editor; the top is QObject, which is the parent class of all controls and even the main interface, which is Qt Basic class; QWidget inherits from QLabel; QFrame inherits from QWidget; QLabel inherits from QFrame; through the property editor, learn the methods and properties of various control classes;
Settings of menu bar and toolbar in QtCreator
The menu bar and toolbar are only available in QMainWindow by default, so when starting a new project, choose to inherit QMainWindow;
Menu bar settings (select QMenuBar in the object editor)
Note: After entering here, you must select the Enter key to succeed, and you cannot exit directly.
If you directly output in the interface under the secondary menu, Chinese input is not supported , you can enter two numbers at will, and then select it, and edit it directly in the action editor
In this way, editing can appear in Chinese
Toolbar settings (select QToolBar in the object editor)
The default toolbar height of Qt itself is very low, you can manually set the height to 30, so that the height looks appropriate;
To add options in the toolbar, you need to use the action editor (if the action editor does not appear in QtCreator, view-action editor). In the
action editor, select New
and the icon can be selected from the resource manager above.
After creating a new one, you can see the newly created QAction object in the action editor;
drag the action editor directly to the toolbar, and you can see icons appear in the toolbar;
Menu bar, toolbar code editing
The menu bar and toolbar are QAction class objects, different from other controls, there is no clicked signal, the signal is triggered
connect(ui.actionOpen, SIGNAL(triggered()), this, SLOT(actionOpenSlot()));