Qt modal dialog box usage (set widget background in UI file, this is a picture with a shaded border--cool)

Source: Internet
Author: User

qt Popup modal dialog box procedure:

1, the new UI file, be sure to choose the base class is Qdialog, my choice is: Dialog without Buttons (), such as:

2, and then in use:

Mydialog Dlg (this);

Dlg.exec ();

If this is not added, a new EXE is created in the Task Manager.

3, if the title of the dialog box is custom, do not want to use the system's title, this time need to add in the code:

Setwindowflags (Qt::D ialog | Qt::framelesswindowhint);

SetAttribute (Qt::wa_translucentbackground);

When setting the window flag, be sure to add: Qt::D ialog, otherwise the dialog box pop-up is not in the form of modal dialog box, will become a non-modal dialog box.

Attached: modal dialog box Custom caption with transparent shaded border:

Main ideas:

1. A widget control is placed on the dialog box, which is used to store the background image;

2, the dialog box is set to untitled, no minimum button style, and the background is completely transparent;

In the dialog box class, initialize join:

Setwindowflags (Qt::D ialog | Qt::framelesswindowhint);
SetAttribute (Qt::wa_translucentbackground);

Set the widget background chart in the UI file, which is a picture with a shaded border:

#widget {Border-image:url (:/images/bk.png)}

http://blog.csdn.net/itjobtxq/article/details/8797360

Qt modal dialog box usage (set widget background in UI file, this is a picture with a shaded border--cool)

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.