Chapter III Window Parts

Source: Internet
Author: User

1 /*3-1 MyWidget1*/2#include <Qtgui>3 4 intMain (intargcChar* argv[])//Why are two parameters? 5 {6 qapplication A (ARGC,ARGV);7QTEXTCODEC::SETCODECFORTR (Qtextcodec::codecforname ("UTF-8"));//in the code, you can use the Chinese8 9Qwidget *widget =NewQwidget ();//new dynamically allocating memoryTenWidget->setwindowtitle (Qobject::tr ("I'm the widget ."));//Qobject::tr in order not to appear garbled One  A  -Qlabel *label =NewQlabel (); -Label->setwindowtitle (Qobject::tr ("I'm a label .")); theLabel->settext (Qobject::tr ("Label: I am a window")); -  -Label->resize ( -, $);//Change part size -  +  -Qlabel *label2=NewQlabel (widgets);//Label2 Specifies that the parent window is a widget, so label2 is not a window +Label2->settext (Qobject::tr ("Label2: I'm not a standalone window, just a widget subassembly")); A   at  -Label->Show (); -Widget->Show (); -    //label2->show (); //because Label2 is not a window, it cannot be displayed. -  -     intret=a.exec (); inDelete label;//Freeing Memory -Delete widget;//will automatically release Label2 to  +     returnRet//Time Cycle -}

Chapter III Window Parts

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.