Qt文件查找对话框(二)


//////////////////////////////////////////////////////////////////////////
// SearchBox.h
#ifndef SearchBox_H
#define SearchBox_H

#include <QDialog>

class QLabel;
class QWidget;
class QHBoxLayout;
class QVBoxLayout;
class QLineEdit;
class QCheckBox;
class QPushButton;


class SearchBox : public QDialog
{
public:
 SearchBox(QWidget *parent = 0);

private:
 QLabel *label;
 QHBoxLayout *layout;
 QVBoxLayout *vlayout;
 QHBoxLayout *mainLayout;
 QVBoxLayout *rightLayout;

 QLineEdit *lineEdit;
 QCheckBox *checkBox_MatchCase;
 QCheckBox *checkBox_Find_Backward;
 QPushButton *pushButton_search;
 QPushButton *pushButton_close;
};

#endif

//////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
// SearchBox.cpp
#include <QDialog>
#include <QLabel>
#include <QWidget>
#include <QBoxLayout>
#include <QLineEdit>
#include <QCheckBox>
#include <QPushButton>

#include "SearchBox.h"

SearchBox::SearchBox(QWidget *parent)
 :QDialog(parent)
{
 label = new QLabel("Find &What");
 layout = new QHBoxLayout();
 vlayout = new QVBoxLayout();
 mainLayout = new QHBoxLayout();
 rightLayout = new QVBoxLayout();
 lineEdit = new QLineEdit();
 checkBox_MatchCase = new QCheckBox("&Match Case");
 checkBox_Find_Backward = new QCheckBox("Find &Backward");
 pushButton_search = new QPushButton("&Search");
 pushButton_close = new QPushButton("&Close");

 label->setBuddy(lineEdit);
 layout->addWidget(label);
 layout->addWidget(lineEdit);
 vlayout->addLayout(layout);
 vlayout->addWidget(checkBox_MatchCase);
 vlayout->addWidget(checkBox_Find_Backward);
 rightLayout->addWidget(pushButton_search);
 rightLayout->addWidget(pushButton_close);
 rightLayout->addStretch();
 
 mainLayout->addLayout(vlayout);
 mainLayout->addLayout(rightLayout);
 
 pushButton_search->setDefault(true);
 pushButton_search->setEnabled(false);
 
 setLayout(mainLayout);
 setWindowTitle("Search");
 setFixedHeight(sizeHint().height());  // 设置适合的高度
}

//////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
// main.cpp
#include <QApplication>
#include "SearchBox.h"

#pragma comment(lib, "QtCore4.lib")
#pragma comment(lib, "QtGui4.lib")

int main(int argc, char **argv)
{
 QApplication *app = new QApplication(argc, argv);
 
 SearchBox *search_box = new SearchBox();
 search_box->show();

 app->exec();
}

//////////////////////////////////////////////////////////////////////////

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值