代码拉取完成,页面将自动刷新
同步操作将从 EarlDoss/spreadsheet 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "finddialog.h"
/* 1.创建并初始化子窗口部件
* 2.把子窗口放到布局中
* 3.设置Tab键顺序
* 4.建立信号-槽之间的连接
* 5.实现对话框中的自定义槽
*/
#include<QtWidgets> //Qt最重要的头文件
FindDialog::FindDialog(QWidget*parent):QDialog(parent) //把parent参数传递给基类构造函数
{
/*********1.创建并初始化子窗口部件**********************/
label=new QLabel(tr("找什么(&W)")); //字符串调用tr函数,翻译成其他语言标记
lineEdit=new QLineEdit;
label->setBuddy(lineEdit); //使用快捷键w将光标放在文本框里
caseCheckBox =new QCheckBox(tr("区分大小写(&C)"));
backwardCheckBox=new QCheckBox(tr("向后查找(&B)"));
findButton =new QPushButton(tr("开始查找(&F)"));
closeButton=new QPushButton(tr("关闭"));
findButton->setDefault(true);
findButton->setEnabled(false);
/*********4.建立信号-槽之间地连接**********************/
connect(lineEdit,SIGNAL(textChanged(QString)), //信号和槽的参数是同一个
this,SLOT(enabledFindButton(QString)));
connect(findButton,SIGNAL(clicked()),
this,SLOT(findClicked()));
connect(closeButton,SIGNAL(clicked()),
this,SLOT(close()));
/*********2.把子窗口放到布局中**********************/
//一个布局就是一个盒子
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);
this->setLayout(mainLayout);
this->setWindowTitle(tr("查找对话框"));
this->setFixedHeight(sizeHint().height()); //创建最佳高度
}
void FindDialog::enabledFindButton(const QString &text)
{
findButton->setEnabled(!text.isEmpty());
}
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);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。