Using smart pointers in Qt

Source: Internet
Author: User

Department of the project, is to use QT to do a graphical interface to send and receive data, but the creation of data management classes need a variety of new, delete, very careful but memory usage in the continuous switching program after the function President, because the use of GCC 4.7.* so there seems to be no shared_ PTR can be used, the Internet to check the original QT also has a smart pointer.

Commonly used are qscopedpointer and qsharedpointer, and the usage is very similar to STD unique_ptr and shared_ptr, like this:

1 2     Writethread (new ncwritethread);

Basically as good as the standard library, the specific here will not repeat it.

Using smart pointers in Qt

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.