VS+Qt resource manager and icon settings, process records set in QtCreator for menu bar and toolbar

Explorer and icon settings steps

  1. qrc is responsible for loading some resource files, which can be seen when the project is newly created

insert image description here
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
insert image description here
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) (
insert image description here
3) Select the original resource file in the project (this step can also be manually filled in the qrc edit column Enter QtMainWindow.qrc) insert image description here(4) Create a new icon folder in the project folder, and put in png, ico and other types of icons in advance; ( insert image description here
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)
insert image description here

(6) Add all the picture files of the icon in the project folder prepared in advance.
insert image description here
So far,
insert image description here
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
insert image description here

property editor

insert image description here
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;
insert image description here

Menu bar settings (select QMenuBar in the object editor)

insert image description here
Note: After entering here, you must select the Enter key to succeed, and you cannot exit directly.
insert image description here
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
insert image description here
In this way, editing can appear in Chinese
insert image description here

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;

insert image description here
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
insert image description here
action editor, select New
insert image description here
and the icon can be selected from the resource manager above.

insert image description here
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;
insert image description here

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()));

Guess you like

Origin blog.csdn.net/qq_43376782/article/details/129785342