LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 920|回复: 2

这段Qt代码中的this就哪个对象的?

[复制链接]
发表于 2007-3-23 08:37:35 | 显示全部楼层 |阅读模式
这是C++GUI Qt3 中的一段代码:
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qpushbutton.h>

#include "finddialog.h"

FindDialog::FindDialog(QWidget *parent, const char *name)
: QDialog(parent,name)
{
setCaption(tr("Find"));

label=new QLabel(tr("Find &what:"), this);
lineEdit=new QLineEdit(this);
label->setBuddy(lineEdit);

caseCheckBox=new QCheckBox(tr("Match &case"),this);
backwardCheckBox=new QCheckBox(tr("Search &backward"),this);

findButton=new QPushButton(tr("&Find"),this);
findButton->setDefault(true);
findButton->setEnabled(false);

closeButton=new QPushButton(tr("Close"),this);

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(1);

QHBoxLayout *mainLayout=new QHBoxLayout(this);
mainLayout->setMargin(11);
mainLayout->setSpacing(6);
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
}

void FindDialog::findClicked()
{
QString text=lineEdit->text();
bool caseSensitive=caseCheckBox->isOn();
if(backwardCheckBox->isOn())
emit findPrev(text,caseSensitive);
else
emit findNext(text,caseSensitive);
}

void FindDialog::enableFindButton(const QString &text)
{
findButton->setEnabled(!text.isEmpty());
}



我的问题是下面的代码中的this是指向哪个对象的?
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()));

谢谢^_^
发表于 2007-3-23 12:45:41 | 显示全部楼层
当前这个类的对象
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-25 12:17:03 | 显示全部楼层
谢谢 ,我明白了。当时不理解slot和singal,现在知道了^_^
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表