Qt relative path Absolute path __QT

Source: Internet
Author: User

Absolute Path:

App.applicationdirpath (): This gets is an absolute path, is the absolute path when the program runs, if is debug mode, absolute path locates to debug file
 
Qdir::currentpath (); This gets the absolute path to the working directory. Click Run in the project to get the path set below. But if you are running directly on debug, you get the path to the current program.

 
 


relative path:

We usually use "./" and ":/". First, let's take a look at "./".

“./”:

The first thing we have to consider is which path is this relative, and this is the path to the working directory, which is Qdir::currentpath ().

Note: The path of Qdir::currentpath () will change, if the project is the path of the engineering directory, if it is not the project, direct operation, get the path of the program, so generally do not use "./" To obtain the path, this time can be loaded with QT QRC. Let's take a look at the following ":/".

":/": This is relatively simple, is QRC inside the path plus ":/" just fine. The following figure, I can use this:

Qfile f (":/gui/stylesheets/black.css");



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.