功能特点:
1.支持以静态对象的方式调用,由于对话框阻塞的特性,所以只会有一个界面被显示,从而实现了一个对象重复使用的目的。
2.本示例是基于自定义窗体实现的,也可以修改为其它基类实现。
调用方式:
QBaseDialog::showDialog(this, _text, _title, _buttonType);
或者
QBaseDialog dialog;
dialog.execDialog(this,"this is dialog","hint");
界面文件:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QBaseDialog</class>
<widget class="QBaseWindow" name="QBaseDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>240</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>11</x>
<y>10</y>
<width>371</width>
<height>221</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="LE_Icon">
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>icon</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="4">
<widget cla

本文介绍了如何在QT中实现一个自定义对话框,该对话框支持静态对象调用,确保在对话框阻塞状态下只有一个界面显示,从而达到对象复用。通过QBaseDialog::showDialog或直接创建dialog对象调用execDialog方法,可以方便地在应用程序中使用这个自定义对话框。示例代码基于自定义窗体,但也适用于其他基类。
最低0.47元/天 解锁文章
678

被折叠的 条评论
为什么被折叠?



