新浪微博
腾讯微博
会员列表
统计排行
基本信息
到访IP统计
管理团队
管理统计
在线会员
会员排行
版块排行
帖子排行
标签排行
帮助
下拉
用户名
电子邮箱
用户名
密 码
记住登录
登录
找回密码
注册
快捷通道
关闭
您还没有登录,快捷通道只有在登录后才能使用。
立即登录
还没有帐号? 赶紧
注册一个
首页
论坛
Qt下载
作品展
群组
个人中心
捐赠、管理与开发
邮件订阅
帖子
文章
日志
用户
版块
群组
帖子
搜索
QTCN开发网
>
《C++ GUI Qt 4编程》(第2版)专栏
>
为啥第二章的第一个例子我在windows下编译执行没反映呢???
发帖
回复
返回列表
新帖
5368
阅读
2
回复
为啥第二章的第一个例子我在windows下编译执行没反映呢???
[复制链接]
上一主题
下一主题
离线
yarco
UID:7193
注册时间
2006-05-28
最后登录
2018-01-16
在线时间
1小时
发帖
3
搜Ta的帖子
精华
0
金钱
30
威望
4
贡献值
0
好评度
3
访问TA的空间
加好友
用道具
禁止发言
关闭
个人中心可以申请新版勋章哦
立即申请
知道了
加关注
发消息
只看楼主
倒序阅读
楼主
发表于: 2009-03-19
为啥第二章的第一个例子我在windows下编译执行没反映呢???
finddialog.h
复制代码
#ifndef FINDDIALOG_H
#define FINDDIALOG_H
#include <QDialog>
class QLabel;
class QLineEdit;
class QCheckBox;
class QPushButton;
class FindDialog : public QDialog
{
Q_OBJECT
public:
FindDialog(QWidget* parent = 0);
signals:
void findNext(const QString& str, Qt::CaseSensitivity cs);
void findPrevious(const QString& str, Qt::CaseSensitivity cs);
private slots:
void findClicked();
void enableFindButton(const QString& str);
private:
QLabel* label;
QLineEdit* lineEdit;
QCheckBox* caseCheckBox;
QCheckBox* backwardCheckBox;
QPushButton* findButton;
QPushButton* closeButton;
};
#endif
finddialog.cpp
复制代码
#include <QtGui>
#include "finddialog.h"
FindDialog::FindDialog(QWidget* parent)
: QDialog(parent)
{
label = new QLabel(tr("Find &what:"));
lineEdit = new QLineEdit;
label->setBuddy(lineEdit);
caseCheckBox = new QCheckBox(tr("Match &case"));
backwardCheckBox = new QCheckBox(tr("Search &backward"));
findButton = new QPushButton(tr("&Find"));
findButton->setDefault(true);
findButton->setEnabled(false);
closeButton = new QPushButton(tr("Close"));
connect(lineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(enableFindButton(const QString &)));
connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked()));
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
QHBoxLayout* topLeftLayout = new QHBoxLayout;
topLeftLayout->addWidget(label);
topLeftLayout->addWidget(lineEdit);
QVBoxLayout* leftLayout = new QVBoxLayout;
leftLayout->addLayout(topLeftLayout);
leftLayout->addWidget(caseCheckBox);
leftLayout->addWidget(backwardCheckBox);
QVBoxLayout* rightLayout = new QVBoxLayout;
rightLayout->addWidget(findButton);
rightLayout->addWidget(closeButton);
rightLayout->addStretch();
QHBoxLayout* mainLayout = new QHBoxLayout;
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
setWindowTitle(tr("Find"));
setFixedHeight(sizeHint().height());
}
void FindDialog::findClicked()
{
QString text = lineEdit->text();
Qt::CaseSensitivity cs = caseCheckBox->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive;
if (backwardCheckBox->isChecked())
{
emit findPrevious(text, cs);
}
else
{
emit findNext(text, cs);
}
}
void FindDialog::enableFindButton(const QString& str)
{
findButton->setEnabled(str.isEmpty());
}
qt_2_dialog.cpp
复制代码
// qt_2_dialog.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <QApplication>
#include "finddialog.h"
int _tmain(int argc, _TCHAR* argv[])
{
QApplication app(argc, argv);
FindDialog* dialog = new FindDialog;
dialog->show();
return app.exec();
}
各位给看看, 应该和书里的一样的啊....
我一编译, 一执行没任何反应...查看进程会有个僵尸进程...
咋回事呢?
另, 象这种情况我如何调试呢?
共
条评分
回复
举报
分享到
淘江湖
新浪
QQ微博
QQ空间
开心
人人
豆瓣
网易微博
百度
鲜果
白社会
飞信
离线
yarco
UID:7193
注册时间
2006-05-28
最后登录
2018-01-16
在线时间
1小时
发帖
3
搜Ta的帖子
精华
0
金钱
30
威望
4
贡献值
0
好评度
3
访问TA的空间
加好友
用道具
禁止发言
加关注
发消息
只看该作者
1楼
发表于: 2009-03-19
我好强啊....这是我的第一个帖子...
各位给点面子啊
忘了说了:
系统环境 windows vista home basic
qt库: 4.4.3 opensource
编译环境: visual studio 2008 c++ express
[ 此帖被yarco在2009-03-19 22:37重新编辑 ]
共
条评分
回复
举报
离线
yarco
UID:7193
注册时间
2006-05-28
最后登录
2018-01-16
在线时间
1小时
发帖
3
搜Ta的帖子
精华
0
金钱
30
威望
4
贡献值
0
好评度
3
访问TA的空间
加好友
用道具
禁止发言
加关注
发消息
只看该作者
2楼
发表于: 2009-03-20
找到了...偶下载了原书的代码一比对...原来少了
setLayout(mainLayout);
// finddialog.cpp
共
条评分
回复
举报
发帖
回复
返回列表
http://www.qtcn.org/bbs
访问内容超出本站范围,不能确定是否安全
继续访问
取消访问
快速回复
限100 字节
您目前还是游客,请
登录
或
注册
进入高级模式
文字颜色
发 布
回复后跳转到最后一页
上一个
下一个
关闭
补充发布信息
验证码:
发 布
隐藏
快速跳转
站务及资讯
网站公告
新闻资讯
Qt官方发布
网站管理
Qt应用及资源
Qt 作品展
Qt代码秀
Qt应用版
Qt技术讨论区
Qt安装与发布
Qt中文处理
Qt基础编程
Qt QML开发
Qt嵌入式开发
Qt移动平台开发
其它技术开发讨论区
Qt图书专区
《C++ GUI Qt 4编程》(第2版)专栏
《Qt高级编程》专栏
《零基础学Qt4编程》专栏
《Qt设计模式》(第2版) 图书专栏
Python Qt GUI快速编程
Qt项目开发区
天池项目
Qt开放平台开发库
Qt版百度云笔记
机械CAD
Qt文档计划
QTCN网站系统开发
扇贝词典
非活跃项目区
社区中心
帖子回收站(Trash)
招聘、求职、供求、广告等
休闲娱乐
关闭
关闭
选中
1
篇
全选