Tips for QT Forms

Source: Internet
Author: User

1. Transparent interface

Setwindowopacity (0.8); // The constructor adds this sentence, 1 is opaque, 0 is completely transparent, and 0.8 is 80% opaque. 

2. Set the background image

Qpixmap pixmap = Qpixmap (":/image/background"). Scaled (this,size ()); Qpalette Palette (This, this,setpalette (palette); /* first add the background to the resource file, note to put the file in an extra copy in the Qtcreator compiled directory, the size is self-adapting, it is recommended to use only PNG images, no installation/other plugins. */

3. Set window No border

    setwindowflags (qt::framelesswindowhint); // In the constructor, you can make the window borderless, noting that the window cannot be moved. 

4. Set the form to move

voidMainwindow::mousepressevent (Qmouseevent *Event){    if(Event->button () = =Qt::leftbutton) {M_drag=true; M_dragposition=Event->globalpos ()- This-POS (); Event-accept (); }}voidMainwindow::mousemoveevent (Qmouseevent *Event){    if(M_drag && (Event->buttons () &&Qt::leftbutton)) {Move (Event->globalpos ()-m_dragposition); Event-accept (); }}voidMainwindow::mousereleaseevent (Qmouseevent *) {M_drag=false;}//Add These three signals after adding <QMouseEvent> in the header file. 

5. Set the input box to password mode

Lineedit_2->setechomode (qlineedit::P assword); // through this section, you can get the password display effect such as:

Tips for QT Forms

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.