Red Hat Enterprice Linux 5测试 Qt 4.7 & Qt Creator(二)

简介:
测试一下Qt 4.7 & Qt Creator科技预览版,写个经典的helloword程序, 双击Qt Creator快捷启动图标,如果配置成功可以看到Qt Creator的欢迎界面
点击File->New File or project Ctrl+N
// 点击文件,新建一个工程
// 选择Qt Application project 下的Qt Gui Application, 然后点击OK
//name想输入工程目录名称为helloworld,创建路径在/root目录下
类名( Class name ): MainWindow
基类 (Base class) QMainWindow
头文件( Header file ): mainwindow.h
源文件( Source file ): mainwindow.cpp
生成表格( Generate form )默认勾上复选框
表格文件( Form file ): mainwindow.ui
然后点击下一步( next
/ 点击 next
//完成以后会调整到下面界面,显示helloworld项目工程创建成功
Ctrl +R或执行run会弹出下面空白界面
现在开始设置了,点击 Forms ,然后双击 mainwindow.ui 文件,弹出下面的设置界面,在 bottons 栏目选择 Push Button 拉到编辑界面。再找到 Input Widgets 窗口部件中的 Line Edit 拉到编辑界面,最后将 Display Widgets 显示窗口部件的 label 拉到编辑界面。接下来是建立信号和槽,选择 Pushbotton, 点击编辑界面的左上角的箭头 , 然后再 Pushbotton 按钮拉一下,会弹出一个 configure Connection 编译连接对话框。 PushBotton(QApplication) 默认选择 clicked ,点击 MainWindow(QMainWindow) 下面的 Edit 编辑
弹出一个信号和槽的编辑对话框( Signals/Slots of MainWindow ),点击槽( slots )下面的 ”+” ,添加一个 buttonClickHandler() 变量
然后点击 OK 完成,信号和槽的设置。
//设置好后可以看到PushButtonbuttonClickHandler()连接上了
// mainwindow.h 头文件中定义一个公共槽函数,
Public slots:
Void buttonClickHandler();
接着在 mainwindow.cpp 添加, buttonClickHandler() 的作用
void MainWindow::buttonClickHandler()
{
 Ui->label->setText(ui->lineEdit->text());
}
执行 Ctrl+R, run, 会弹出 Save Changes 对话框,然后选择 Save All 保存文件。也可以选选择保存,会不会弹出那个对话框了,然后再执行  run Ctrl+R 运行程序
测试一下效果,在 lineEdit 输入窗口配置中输入 Hello Qt world!  然后点击 PushButton 就可以看到 textlabel 上显示, hello Qt world      !
显示效果如下:
 
但安装好的软件执行编译时有个问题,可能由于安装平台的关系,有些库文件无法找到。
(<unknown>:9162): GLib-GObject-WARNING **: IA__g_object_set_valist: object class `GtkMenuItem' has no property named `label'
(<unknown>:9162): GLib-GObject-WARNING **: IA__g_object_set_valist: object class `GtkCheckMenuItem' has no property named `label'
< 未知 > 9162 ): GLib - GObject 的预警 ** IA__g_object_set_valist :对象类 `GtkMenuItem' 有一个名为 ' 标签没有属性 '
< 未知 > 9162 ): GLib - GObject 的预警 ** IA__g_object_set_valist :对象类 `GtkCheckMenuItem' 有一个名为 ' 标签没有属性 '
 
 
 
今天就到这里了。。。。。
 
今天就到这里了!
 









本文转自 chen138 51CTO博客,原文链接:http://blog.51cto.com/chenboqiang/309218,如需转载请自行联系原作者

目录
相关文章
|
2月前
|
安全 Linux 数据安全/隐私保护
Red Hat Enterprise Linux 9.6 (x86_64, aarch64) - 红帽企业 Linux (RHEL)
Red Hat Enterprise Linux 9.6 (x86_64, aarch64) - 红帽企业 Linux (RHEL)
296 36
Red Hat Enterprise Linux 9.6 (x86_64, aarch64) - 红帽企业 Linux (RHEL)
|
2月前
|
安全 Unix Linux
Metasploit Pro 4.22.7-2025052201 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.7-2025052201 (Linux, Windows) - 专业渗透测试框架
80 5
Metasploit Pro 4.22.7-2025052201 (Linux, Windows) - 专业渗透测试框架
|
2月前
|
安全 前端开发 Linux
Immunity CANVAS Professional 7.27 (macOS, Linux, Windows) - 渗透测试和漏洞利用平台
Immunity CANVAS Professional 7.27 (macOS, Linux, Windows) - 渗透测试和漏洞利用平台
100 3
Immunity CANVAS Professional 7.27 (macOS, Linux, Windows) - 渗透测试和漏洞利用平台
|
2月前
|
安全 测试技术 Linux
Flawnter 5.9.1 (macOS, Linux, Windows) - 应用程序安全测试软件
Flawnter 5.9.1 (macOS, Linux, Windows) - 应用程序安全测试软件
97 2
Flawnter 5.9.1 (macOS, Linux, Windows) - 应用程序安全测试软件
|
2月前
|
数据采集 安全 Linux
Metasploit Pro 4.22.7-2025051201 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.7-2025051201 (Linux, Windows) - 专业渗透测试框架
53 4
Metasploit Pro 4.22.7-2025051201 (Linux, Windows) - 专业渗透测试框架
|
2月前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.63 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.63 (macOS, Linux, Windows) - 开源渗透测试框架
69 4
Metasploit Framework 6.4.63 (macOS, Linux, Windows) - 开源渗透测试框架
|
2月前
|
人工智能 安全 Linux
Red Hat Enterprise Linux 10 正式版发布 - 红帽企业 Linux (RHEL)
Red Hat Enterprise Linux 10 正式版发布 - 红帽企业 Linux (RHEL)
309 0
Red Hat Enterprise Linux 10 正式版发布 - 红帽企业 Linux (RHEL)
|
3月前
|
存储 安全 Linux
Metasploit Pro 4.22.7-2025040601 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.7-2025040601 (Linux, Windows) - 专业渗透测试框架
148 1
Metasploit Pro 4.22.7-2025040601 (Linux, Windows) - 专业渗透测试框架
|
3月前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.55 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.55 (macOS, Linux, Windows) - 开源渗透测试框架
93 0
Metasploit Framework 6.4.55 (macOS, Linux, Windows) - 开源渗透测试框架
|
5月前
|
人工智能 Linux iOS开发
Burp Suite Professional 2025.2 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
Burp Suite Professional 2025.2 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
232 12
Burp Suite Professional 2025.2 (macOS, Linux, Windows) - Web 应用安全、测试和扫描