﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Sophie</title><link>http://www.cppblog.com/sophy/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 14 Apr 2026 23:07:18 GMT</lastBuildDate><pubDate>Tue, 14 Apr 2026 23:07:18 GMT</pubDate><ttl>60</ttl><item><title>Qt中添加自定义Slot函数的方法（VS2010+Qt4.7.0）</title><link>http://www.cppblog.com/sophy/archive/2010/11/03/132350.html</link><dc:creator>Sophie</dc:creator><author>Sophie</author><pubDate>Wed, 03 Nov 2010 15:03:00 GMT</pubDate><guid>http://www.cppblog.com/sophy/archive/2010/11/03/132350.html</guid><wfw:comment>http://www.cppblog.com/sophy/comments/132350.html</wfw:comment><comments>http://www.cppblog.com/sophy/archive/2010/11/03/132350.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/sophy/comments/commentRss/132350.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sophy/services/trackbacks/132350.html</trackback:ping><description><![CDATA[
<div class="Section0" style="layout-grid:15.6000pt;"><p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; "><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:12.0000pt; font-family:'Times New Roman'; "><span class="Apple-tab-span" style="white-space:pre">	</span>相对于用代码生成界面来讲，使用<font face="Times New Roman">QtDesigner</font><font face="宋体">来直接设计界面不失为一个更快捷直观的方法。在添加完控件后，怎么进行信号和槽的连接呢？</font><font face="Times New Roman">Qt&nbsp;Designer</font><font face="宋体">中提供了一</font><font face="Times New Roman">"Singal/Slot&nbsp;Editor"</font><font face="宋体">，对于已有的信号和槽，直接新建，选择相应的</font><font face="Times New Roman">Signal</font><font face="宋体">和</font><font face="Times New Roman">slot</font><font face="宋体">就好了。可是往往我们需要编写自己的</font><font face="Times New Roman">Slot</font><font face="宋体">函数，这时应该怎么添加呢？有以下几种方法：</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:12.0000pt; font-family:'Times New Roman'; "><o:p></o:p></span></p><p class="p0" style="margin-bottom:0pt; margin-top:0pt; border-top:none; ; mso-border-top-alt:none; ; border-right:none; ; mso-border-right-alt:none; ; border-bottom:none; ; mso-border-bottom-alt:none; ; border-left:none; ; mso-border-left-alt:none; ; padding:24pt 24pt 24pt 24pt ; text-autospace:ideograph-other; "><span style="mso-spacerun:'yes'; font-size:12.0000pt; font-family:'Times New Roman'; ">1.<font face="宋体">按照一定的格式规范命名</font><font face="Times New Roman">Slot</font><font face="宋体">函数，</font><font face="Times New Roman">setupUi()</font><font face="宋体">函数可以自动将符合</font><font face="Times New Roman">on_objectName_signalName()</font><font face="宋体">命名的槽与形影的</font><font face="Times New Roman">ObjectName</font></span><span style="mso-spacerun:'yes'; font-size:12.0000pt; font-family:'Times New Roman'; ">的<font face="Times New Roman">SignalName</font><font face="宋体">连接在</font></span><span style="mso-spacerun:'yes'; font-size:12.0000pt; font-family:'Times New Roman'; ">一起。</span></p><p class="p0" style="margin-bottom:0pt; margin-top:0pt; border-top:none; ; mso-border-top-alt:none; ; border-right:none; ; mso-border-right-alt:none; ; border-bottom:none; ; mso-border-bottom-alt:none; ; border-left:none; ; mso-border-left-alt:none; ; padding:24pt 24pt 24pt 24pt ; text-autospace:ideograph-other; "><span style="mso-spacerun:'yes'; font-size:12.0000pt; font-family:'Times New Roman'; "><span  style="font-size: medium; "><span style="mso-spacerun:'yes'; font-size:12.0000pt; font-family:'Times New Roman'; ">例如<font face="Times New Roman">UI</font><font face="宋体">里新建了一个</font><font face="Times New Roman">openButton</font><font face="宋体">，在</font><font face="Times New Roman">.h</font><font face="宋体">文件里声明</font><font face="Times New Roman">void&nbsp;on_openButton_clicked()</font><font face="宋体">函数并在</font><font face="Times New Roman">cpp</font><font face="宋体">文件里添加这个函数的定义后，</font><font face="Times New Roman">seupUi</font><font face="宋体">（）就可以自动将</font><font face="Times New Roman">openButton</font><font face="宋体">的</font><font face="Times New Roman">clicked</font><font face="宋体">信号与我们定义的</font><font face="Times New Roman">slot</font><font face="宋体">函数联系在一起了！</font></span><span style="mso-spacerun:'yes'; font-size:12.0000pt; font-family:'Times New Roman'; ">例如<font face="Times New Roman">UI</font><font face="宋体">里新建了一个</font><font face="Times New Roman">openButton</font><font face="宋体">，在</font><font face="Times New Roman">.h</font><font face="宋体">文件里声明</font><font face="Times New Roman">void&nbsp;on_openButton_clicked()</font><font face="宋体">函数并在</font><font face="Times New Roman">cpp</font><font face="宋体">文件里添加这个函数的定义后，</font><font face="Times New Roman">seupUi</font><font face="宋体">（）就可以自动将</font><font face="Times New Roman">openButton</font><font face="宋体">的</font><font face="Times New Roman">clicked</font><font face="宋体">信号与我们定义的</font><font face="Times New Roman">slot</font><font face="宋体">函数联系在一起了！</font></span></span></span></p><p class="p0" style="margin-bottom:0pt; margin-top:0pt; border-top:none; ; mso-border-top-alt:none; ; border-right:none; ; mso-border-right-alt:none; ; border-bottom:none; ; mso-border-bottom-alt:none; ; border-left:none; ; mso-border-left-alt:none; ; padding:24pt 24pt 24pt 24pt ; text-autospace:ideograph-other; "><span  style="font-size: 16px; ">2.<font face="宋体">直接在</font><font face="Times New Roman">.h</font><font face="宋体">文件和</font><font face="Times New Roman">cpp</font><font face="宋体">文件里定义</font><font face="Times New Roman">slot</font><font face="宋体">函数，例如</font><font face="Times New Roman">void&nbsp;open();</font><font face="宋体">进入到</font><font face="Times New Roman">Edit&nbsp;Signal&nbsp;and&nbsp;slots</font><font face="宋体">模式下，在我们要响应</font><font face="Times New Roman">slot</font><font face="宋体">函数的控件上滑动鼠标左键，便会出来一个</font><font face="Times New Roman">Configure&nbsp;connection</font><font face="宋体">的对话框，点</font><font face="Times New Roman">Edit</font><font face="宋体">，这时我们需要的</font><font face="Times New Roman">open</font><font face="宋体">函数出现啦，选择这个函数，就完成了信号和槽的连接。在</font><font face="Times New Roman">Edit</font><font face="宋体">里我们还能新建新的槽，先新建，再添代码也能达到同样的目的</font><font face="Times New Roman">~</font></span></p><p class="p0" style="margin-bottom:0pt; margin-top:0pt; border-top:none; ; mso-border-top-alt:none; ; border-right:none; ; mso-border-right-alt:none; ; border-bottom:none; ; mso-border-bottom-alt:none; ; border-left:none; ; mso-border-left-alt:none; ; padding:24pt 24pt 24pt 24pt ; text-autospace:ideograph-other; "><span  style="font-size: 16px; ">感言：作为一个<font face="Times New Roman">Qt</font><font face="宋体">新手而言，光折腾这个槽的问题就折腾了好几天</font><font face="Times New Roman">...</font><font face="宋体">写下来给跟我一样的</font><font face="Times New Roman">Qt</font><font face="宋体">菜鸟们一个借鉴</font><font face="Times New Roman">~~</font></span></p><p class="p0" style="margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-size:12.0000pt; font-family:'Times New Roman'; "><o:p></o:p></span></p></div><img src ="http://www.cppblog.com/sophy/aggbug/132350.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sophy/" target="_blank">Sophie</a> 2010-11-03 23:03 <a href="http://www.cppblog.com/sophy/archive/2010/11/03/132350.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Qt学习新进展！可以用QtDesigner设计界面啦~</title><link>http://www.cppblog.com/sophy/archive/2010/11/02/132213.html</link><dc:creator>Sophie</dc:creator><author>Sophie</author><pubDate>Tue, 02 Nov 2010 15:20:00 GMT</pubDate><guid>http://www.cppblog.com/sophy/archive/2010/11/02/132213.html</guid><wfw:comment>http://www.cppblog.com/sophy/comments/132213.html</wfw:comment><comments>http://www.cppblog.com/sophy/archive/2010/11/02/132213.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/sophy/comments/commentRss/132213.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sophy/services/trackbacks/132213.html</trackback:ping><description><![CDATA[
今天一天都是在看有限差分算法中度过的..我承认我的数学水平太差了，那些公式没有几个能看懂的...哎~没有搞算法真是明智的选择啊~<div>不过今天还是有一点小收获的：利用QtDesigner设计程序那个小例子终于调试成功啦~之前总是告诉我没有定义的错误...</div><div>问题出在了那个UI上..现在不早了，回去再贴代码和总结~</div><div><br></div><img src ="http://www.cppblog.com/sophy/aggbug/132213.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sophy/" target="_blank">Sophie</a> 2010-11-02 23:20 <a href="http://www.cppblog.com/sophy/archive/2010/11/02/132213.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>列个Qt要学习的内容</title><link>http://www.cppblog.com/sophy/archive/2010/11/01/132024.html</link><dc:creator>Sophie</dc:creator><author>Sophie</author><pubDate>Mon, 01 Nov 2010 10:48:00 GMT</pubDate><guid>http://www.cppblog.com/sophy/archive/2010/11/01/132024.html</guid><wfw:comment>http://www.cppblog.com/sophy/comments/132024.html</wfw:comment><comments>http://www.cppblog.com/sophy/archive/2010/11/01/132024.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/sophy/comments/commentRss/132024.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sophy/services/trackbacks/132024.html</trackback:ping><description><![CDATA[





中午因为看Qt没有午睡，结果现在就感觉一点儿精神也没有了...真是中午不睡，晚上崩溃...<div>列一个Qt需要学习的内容表：</div><div><span class="Apple-tab-span" style="white-space:pre">	</span>创建菜单栏、任务栏、状态栏；</div><div><span class="Apple-tab-span" style="white-space:pre">	</span>使用splitter完成界面各个功能模块的划分</div><div><span class="Apple-tab-span" style="white-space:pre">	</span>Qt调用ActiveX控件</div><div><span class="Apple-tab-span" style="white-space:pre">	</span>Qt调用Dll</div><div><span class="Apple-tab-span" style="white-space:pre">	</span>利用双缓冲技术进行绘图</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;要开始学习算法了，拿起师姐的毕业论文开始看，突然发现自己连微分方程是什么都不知道了..囧.就我这水平恐怕读博是太困难了....以前怎么就没怎么好好学习数学呢..对于那些数学NB的人来讲，数学应该是美的；对我来说，数学是一直以来的痛....</div><div><span class="Apple-tab-span" style="white-space:pre">	</span>不管怎么样，我还是明天去图书馆借本数值分析的书来看吧，争取在毕业之前弄明白微分方程是怎么回事，以后给孩子讲起来，咱也是学过数学的.....</div><img src ="http://www.cppblog.com/sophy/aggbug/132024.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sophy/" target="_blank">Sophie</a> 2010-11-01 18:48 <a href="http://www.cppblog.com/sophy/archive/2010/11/01/132024.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Qt学习</title><link>http://www.cppblog.com/sophy/archive/2010/11/01/131948.html</link><dc:creator>Sophie</dc:creator><author>Sophie</author><pubDate>Mon, 01 Nov 2010 01:32:00 GMT</pubDate><guid>http://www.cppblog.com/sophy/archive/2010/11/01/131948.html</guid><wfw:comment>http://www.cppblog.com/sophy/comments/131948.html</wfw:comment><comments>http://www.cppblog.com/sophy/archive/2010/11/01/131948.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/sophy/comments/commentRss/131948.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sophy/services/trackbacks/131948.html</trackback:ping><description><![CDATA[
为什么感觉QtDesigner这方面的学习资料很少呢...相对于手写代码生成界面，我还是更喜欢QtDesigner可视化的方式..没办法，只能自己啃Qt Assistant了....<img src ="http://www.cppblog.com/sophy/aggbug/131948.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sophy/" target="_blank">Sophie</a> 2010-11-01 09:32 <a href="http://www.cppblog.com/sophy/archive/2010/11/01/131948.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>博客开张啦~</title><link>http://www.cppblog.com/sophy/archive/2010/10/28/131668.html</link><dc:creator>Sophie</dc:creator><author>Sophie</author><pubDate>Thu, 28 Oct 2010 14:13:00 GMT</pubDate><guid>http://www.cppblog.com/sophy/archive/2010/10/28/131668.html</guid><wfw:comment>http://www.cppblog.com/sophy/comments/131668.html</wfw:comment><comments>http://www.cppblog.com/sophy/archive/2010/10/28/131668.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/sophy/comments/commentRss/131668.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sophy/services/trackbacks/131668.html</trackback:ping><description><![CDATA[今天博客第一天开张啦~<div>这一周真是太倒霉了：周一本来想好好做一次荧光实验，结果不小心（不太清楚是哪儿出了问题，可能是因为我换同步信号线的时候短路了）把激光器弄坏了，导致我这两个月都没有实验可做了....这还是小事，大事是高老师的课题快要中期检查了，没有实验怎么演示呀。而且师兄急着毕业，师姐急着发论文还靠这个激光器呢。555...我真是罪过大了。明天赶紧把它寄过去返修，十天后一定要把那个备用的激光器从北京要过来！天呐，这种倒霉事情怎么就让我遇到了呢...我以后做实验一定要万分小心！都是几十万的仪器啊。</div><div>今天是我的阳历生日~收到了徒弟寄过来的枚红色小挎包~开心呀~那个鲜艳的颜色一看就是俺可爱滴徒弟滴风格，让我买可不买这么鲜艳的...不过换换风格也是好的....</div><div>今天去听了一个叫和利时的公司的宣讲会，一开始的那个HR挺会说的，挺能调动现场气氛~不过接下来那个部长（应该是搞技术的）讲的就太拖沓了，我和朝听到七点多就撤了...我旁边坐了个HGD通信专业的姐姐，我听得实在不耐烦了就跟她聊了下~哎，找工作真不容易呀，人家为了听宣讲会NKTU到处跑。她给了我两点建议挺不错的：一是找工作要提前找好方向，趁早准备；二是平时要积累好论文的素材，这样到时候就不会手忙脚乱了~其实这也是我平时注意的，只是有时候会忽略，她又给我提了个醒~</div><div>好好科研，好好学习，好好生活！</div><img src ="http://www.cppblog.com/sophy/aggbug/131668.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sophy/" target="_blank">Sophie</a> 2010-10-28 22:13 <a href="http://www.cppblog.com/sophy/archive/2010/10/28/131668.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>