在 Linux 中打开 qt designer 3,选择 File->New... ,出现如下窗口:
选择第一个,C++ Project,点 OK 按钮,接着要设置一下它存储的位置:
我把它命名为 hellobtn.pro,存储在 /root/learn/qt/hellobtn 目录里,点 OK。再选择菜单 File->New...,继续选择其中的 C++ Source File,点 OK。
输入如下代码,并保存文件为 htllobtn.cpp 到目录 /root/learn/qt/hellobtn 中。
打开系统工具 Termial,然后依次执行如下命令:
cd /root/learn/qt/hellobtn
qmake hellobtn.pro
make
./hellobtn
这样就可以得到如下所示的窗口:
接下来又做了一个 dialog 的例子。
点击 Qt Designer 菜单 File->New... 选择其中的 C++ Project,保存在目录/root/learn/qt/hellodialog 中。
点击 Qt Designer 菜单 File->New... 选择其中的 Dialog
向 form 中添加一个 textLabel 和一个 pushButton
选中 pushButton1,然后选择 qt designer 的菜单 Edit->Connections...并添加一个事件
选择 qt designer 的菜单 File->New...选择其中的 C++ Main-File
简单配置一下,选中 Form1
会生成下面的代码:
选择 qt designer 的菜单 File->Save All,会提示需要保存 form1.ui,把它保存在 /root/learn/qt/hellodialog 目录中。
打开系统工具 Termial,然后依次执行如下命令:
cd /root/learn/qt/hellodialog
qmake hellodialog.pro
make
./hellodialog
这样就可以得到如下所示的窗口:
点击上面的 pushButton1 则会关闭当前的窗口。
WebKit 学习笔记(4) -- qt 的 helloworld 程序
最新推荐文章于 2020-05-05 15:10:59 发布