1. 主要介绍了QGridLayout, QHBoxLayout, QVBoxLayout3种布局管理器的使用方法。

2. 在linux中,继承自QDialog的对话框,没有最大化、最小化、关闭按钮,如果需要这3个按钮,

需要增加:  setWindowFlags(Qt::Widget);

在windows中,即使不加:setWindowFlags(Qt::Widget); 也会有最大化、最小化、关闭按钮。

3. findfiledialog.h

 /**/
#ifndef FINDFILEDIALOG_H
#define FINDFILEDIALOG_H #include <QDialog> class QLabel;
class QLineEdit;
class QPushButton;
class QCheckBox;
class QTableWidget;
class QHBoxLayout;
class QVBoxLayout;
class QGridLayout; class FindFileDialog : public QDialog
{
Q_OBJECT public:
FindFileDialog(QWidget *parent = ); private:
QLabel *namedLabel;
QLabel *lookInLabel;
QLineEdit *namedLineEdit;
QLineEdit *lookInLineEdit;
QCheckBox *subfoldersCheckBox;
QTableWidget *tableWidget;
QLabel *messageLabel; QPushButton *findButton;
QPushButton *stopButton;
QPushButton *closeButton;
QPushButton *helpButton; QGridLayout *leftLayout;
QVBoxLayout *rightLayout;
QHBoxLayout *mainLayout;
}; #endif

4. findfiledialog.cpp

 /**/
#include "findfiledialog.h" #include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QCheckBox>
#include <QTableWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout> FindFileDialog::FindFileDialog(QWidget *parent)
: QDialog(parent)
{
namedLabel = new QLabel(tr("&Named:"));
namedLineEdit = new QLineEdit;
namedLabel->setBuddy(namedLineEdit); lookInLabel = new QLabel(tr("&Look in:"));
lookInLineEdit = new QLineEdit;
lookInLabel->setBuddy(lookInLineEdit); subfoldersCheckBox = new QCheckBox(tr("Include subfolders")); QStringList labels;
labels << tr("Name") << tr("In Folder")
<< tr("Size") << tr("Modified"); tableWidget = new QTableWidget;
tableWidget->setColumnCount();
tableWidget->setHorizontalHeaderLabels(labels); messageLabel = new QLabel(tr("0 files found"));
messageLabel->setFrameShape(QFrame::Panel);
messageLabel->setFrameShadow(QFrame::Sunken); /* QGridLayout
void addWidget(QWidget * widget,
int fromRow,int fromColumn,
int rowSpan,int columnSpan,
Qt::Alignment alignment = 0)
*/
leftLayout = new QGridLayout;
leftLayout->addWidget(namedLabel, , );
leftLayout->addWidget(namedLineEdit, , );
leftLayout->addWidget(lookInLabel, , );
leftLayout->addWidget(lookInLineEdit, , );
/*subfoldersCheckBox的位置坐标(2, 0),占1行,占2列*/
leftLayout->addWidget(subfoldersCheckBox, , , , );
leftLayout->addWidget(tableWidget, , , , );
leftLayout->addWidget(messageLabel, , , , ); findButton = new QPushButton(tr("&Find"));
stopButton = new QPushButton(tr("&Stop"));
closeButton = new QPushButton(tr("&Close"));
helpButton = new QPushButton(tr("&Help")); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); rightLayout = new QVBoxLayout;
rightLayout->addWidget(findButton);
rightLayout->addWidget(stopButton);
rightLayout->addWidget(closeButton);
rightLayout->addStretch();
rightLayout->addWidget(helpButton); mainLayout = new QHBoxLayout;
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout); setLayout(mainLayout);
setWindowTitle(tr("Find Files or Folders"));
/*在linux中,继承自QDialog的对话框没有最大化最小化和关闭按钮*/
setWindowFlags(Qt::Widget); /*在linux中让对话框有最大最小和关闭按钮*/
}

5. main.cpp

 /**/
#include <QApplication>
#include "findfiledialog.h" int main(int argc, char *argv[])
{
QApplication app(argc, argv); FindFileDialog dialog;
dialog.show(); return app.exec();
}

6. 不带关闭按钮:

带关闭按钮:

C++ GUI Qt4编程(12)-6.1FindFileDialog的更多相关文章

  1. C++ GUI Qt4编程(10)-3.4spreadsheet

    1. C++ GUI Qt4编程第三章,增加spreadsheet. 2. spreadsheet.h /**/ #ifndef SPREADSHEET_H #define SPREADSHEET_H ...

  2. C++ GUI Qt4编程(09)-3.3spreadsheet-toolbar

    1. C++ GUI Qt4编程第三章,增加工具栏.状态栏和快捷键. 2. mainwindow.h /**/ #ifndef MAINWINDOW_H #define MAINWINDOW_H #i ...

  3. C++ GUI Qt4编程(08)-3.2spreadsheet-resource

    1. C++ GUI Qt4编程第三章,图片使用资源机制法. 2. 步骤: 2-1. 在resource文件夹下,新建images文件,存放图片. 2-2. 新建spreadsheet.qrc文件,并 ...

  4. C++ GUI Qt4编程(07)-3.1menu

    1. C++ GUI Qt4编程第三章,添加menu菜单. 2. mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include < ...

  5. C++ GUI Qt4编程(03)-1.3layout

    1. 根据C++ GUI Qt4编程(第二版)整理2. 系统:centos7:  Qt版本:5.5.13. 程序:layout.cpp #include <QApplication> #i ...

  6. C++ GUI Qt4编程(02)-1.2quit

    1. 根据C++ GUI Qt4编程(第二版)整理2. 系统:centos7:  Qt版本:5.5.13. 程序:quit.cpp #include <QApplication> #inc ...

  7. C++ GUI Qt4编程(01)-1.1Hello Qt

    1. 根据C++ GUI Qt4编程(第二版)整理2. 系统:centos7:  Qt版本:5.5.13. 程序:hello.cpp #include <QApplication> #in ...

  8. C++ GUI Qt4编程-创建自定义窗口部件

    C++ GUI Qt4编程-创建自定义窗口部件   Qtqt4 通过Qt窗口部件进行子类化或者直接对QWidget进行子类化,就可以创建自定义窗口部件,下面示范两种方式,并且也会说明如何把自定义窗口部 ...

  9. C++ GUI Qt4 编程 (第二版)

    [加拿大]JasminBlanchette [英]MarkSummerfield . 电子工业 2008. 前几天的问题多是因为版本不兼容的问题. QT本身Q4 Q5就有版本问题,然后集成到VS08 ...

随机推荐

  1. Luogu 3241 [HNOI2015]开店

    BZOJ 4012权限题 浙科协的网突然炸了,好慌…… 据说正解是动态点分治,然而我并不会,我选择树链剖分 + 主席树维护. 设$dis_i$表示$i$到$root(1)$的值,那么对于一个询问$u$ ...

  2. 三维GIS

    三维GIS数据结构 三维GIS数据库 三维渲染显示 点云处理 cnki:http://kns.cnki.net/kns/brief/default_result.aspx

  3. Ubuntu下vi编辑器不听话

    编辑文件/etc/vim/vimrc.tiny,将“compatible”改成“nocompatible”非兼容模式: 并添加一句:set backspace=2 

  4. unity中播放视频

    unity中播放视频步骤如下: 1.将要播放的视频拖入projec.(注意:unity一般支持的视频格式有mov, .mpg, .mpeg, .mp4,.avi, .asf格式  ) 2.在场景中添加 ...

  5. 21天学通C++学习笔记(三):变量和常量

    1. 简述 内存是一种临时存储器,也被称为随机存取存储器(RAM),所有的计算机.智能手机及其他可编程设备都包含微处理器和一定数量的内存,用地址来定位不同的存储区域,像编号一样. 硬盘可以永久的存储数 ...

  6. 光猫烽火Hg220破解超级口令实用图文教程(亲测)

    1.用光猫背后的useradmin 帐号和密码登录 192.168.1.12.然后下载http://192.168.1.1/backupsettings.conf3.用记事本打开,ctrl+F,查找关 ...

  7. VS2013安装及破解教程

    https://blog.csdn.net/qq_33742119/article/details/80075352 软件下载的百度云链接,也可以在官网直接下载 链接:https://pan.baid ...

  8. vmware vSphere虚拟网络(一)

    为了更好的了解vSphere网络虚拟化解决方案,这里引入了一些概念,以便我们更好的了解虚拟网络. 一.网卡: 物理网卡称为vmnic,在ESXi中,第一块物理网卡叫做vmnic0,第二块叫做vmnic ...

  9. Calendar时间类的一些用法

    Calendar 类是一个抽象类,它为特定瞬间与一组诸如 YEAR.MONTH.DAY_OF_MONTH.HOUR 等 日历字段之间的转换提供了一些方法,并为操作日历字段(例如获得下星期的日期)提供了 ...

  10. 错误代码: 1142 REFERENCES command denied to user 'wuyong'@'localhost' for table 'orders'

    错误代码: 1142 REFERENCES command denied to user 'wuyong'@'localhost' for table 'orders' 原因:在使用SQLyog操作数 ...