QT Learning Pathway (13): Menus and Sidebar (cont.)

Source: Internet
Author: User
Tags resource root directory

We've added qaction to menus and toolbars in the previous section. Now we're going to add some pictures to beautify it and then put the signal slots together so that our action can be matched!

First, add an icon. The qaction icon appears in front of the menu item and on the toolbar button.

To add an icon, we first need to use the QT resource file. Right-click on the Qtcreator item, select New File ..., and then select Resource file.

Then click Next, choose a good location, finish. For ease of use, I have built this file in the root directory, the proposal should be carefully planned after the file, built in a special Rsources folder. When finished, a. qrc file is generated, QRC is actually the abbreviation for QT Recource collection. It's just an ordinary XML file that can be opened with Notepad and so on. However, here we do not delve into its structure, completely using Qtcreator to manipulate this file,

Click the Add button, first select Add prefix, and then change the generated/new/prefix to/. This is prefix is the prefix that you need to provide when you use the icon later to/begin. After adding the prefix, add an icon to the project file, select Add File, and select the icon. After this completes, save the QRC file.

To illustrate, Qtoolbar's icon size defaults to 32*32, and the menu defaults to 16*16. If the supplied icon is less than the required size, QT does not enlarge the picture for you, otherwise, if the supplied icon file is larger than the corresponding size requirement, such as 64*64,QT will automatically shrink the size.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.