当前位置:   article > 正文

QT使用QListWidget显示多张图片_qlistwidget显示图片

qlistwidget显示图片

Qt系列文章目录

前言

QListWidget类提供了一个基于项目的列表小部件
QListWidget是一个方便的类,它提供了一个列表视图,类似于QListView提供的列表视图,但是具有一个用于添加和删除项的经典基于项的接口。QListWidget使用一个内部模型来管理列表中的每个QListWidgetItem。要获得更灵活的列表视图小部件,请使用带有标准模型的QListView类。列表小部件的构造方法与其他小部件相同。QListWidget与QListView类似,都可以显示一列Item,区别在于前者可以往其中增删Item。
QListWidget确定可以同时选择列表中的多少项,以及是否可以创建复杂的项选择。这可以使用函数设置

一、QListWidget 和 QListView 的差异

QListWidget 是一个更新且更高级的元件,能够更为方便地进行开发,例如 QListWidget 具有 QStantandardItemModel 无法访问的类型,也能更轻鬆的透过 QListWidgetItem 处理数据,然而如果使用 QListView,许多方法必须要额外定义,属于比较旧的使用方式。

QListView、QListWidget是列表形式展示的控件。

QTableView、QTableWidget是表格形式展示控件。

继承关系:带Widget的继承自View,即:QListWidget是继承QListView,QTableWidget继承自QTableView。

区别:QListView是基于Model,而QListWidget基于Item。这是它们的本质区别。QTableView、QTableWidget同理。

由于QListView和QTableView是基于model的,需要自己来建模(例如建立QStringListModel、QSqlTableModel等),保存数据,这样就大大降低了数据冗余,提高了程序的效率,以及能更方便的进行我们自己需要展示的内容,但是需要我们对数据建模有一定了解。

而QListWidget相当于是QListView的升级版,它已经自己为我们建立了一个数据存储模型(QListWidgetItem),操作方便,直接调用addItem即可添加项目(ICON,文字)。QTableView、QTableWidget同理。

二、显示效果

在这里插入图片描述

1.操作工作区界面

1.主界面头文件

#pragma

#include "ui_QDockWidgetDemo.h"
#include "MsgBox.h"

#include <QMainWindow>
#include <QDockWidget>
#include <QTextEdit>
#include <QPushButton>
#include <QKeyEvent>

#include "propertyWin.h"
#include "projectWin.h"

#include "FileMonitorMgr.h"

QT_FORWARD_DECLARE_CLASS(QMenu)

class QDockWidgetDemo : public QMainWindow
{
	Q_OBJECT

public:
	explicit QDockWidgetDemo(QWidget* parent = nullptr);

private slots:
	void addLog(const QString&);

	//标题栏槽函数
	void s_showToolBar();
	void s_showPorjectWin();
	void s_showPropertyWin();
	void s_showLogWin();
	void s_monitorFile();

	void s_close();
	void s_min();

	void s_hideProj();
	void s_propertyWinHide(bool);
	void s_logWinHide(bool);
	void s_timeout();

	void s_MonitorFolder();
	void s_saveFile();
	void s_runAc();
	void s_stopAc();
	void s_debugAc();
	void s_anaysisAc();
	void s_recordAc();
	void s_grabAc();
	void s_capacityAc();
	void s_paramterAc();
	void s_publishAc();
	void s_exportAc();

private:
	void initTitleBar();
	void initLogView();
	void initWorkSpaceView();
	void initPropertyView();
	void initProjectView();
	void initToolBar();
	void dockLayout();
	void initMaxMinWin();

	void initShowImage();

	void showMessageBox(const QString&);

private:
	Ui::QDockWidgetDemo ui;

	//标题栏
	QAction* m_toolBarAc = NULL;
	QAction* m_projectAc = NULL;
	QAction* m_logAc = NULL;
	QAction* m_propertyAc = NULL;

	//工具栏
	QAction* m_newAc = NULL;
	QAction* m_saveAc = NULL;
	QAction* m_runAc = NULL;
	QAction* m_stopAc = NULL;
	QAction* m_debugAc = NULL;
	QAction* m_anaysisAc = NULL;
	QAction* m_recordAc = NULL;
	QAction* m_grabAc = NULL;
	QAction* m_capacityAc = NULL;
	QAction* m_paramterAc = NULL;
	QAction* m_publishAc = NULL;
	QAction* m_exportAc = NULL;

	QDockWidget* m_logView = NULL;
	QDockWidget* m_propertyView = NULL;
	QDockWidget* m_projManagerView = NULL;

	QTextEdit* m_logBody = NULL;
	QWidget* m_maxminWin = NULL;
	QWidget* m_workspace = NULL;
	projectWin* m_projectWin = NULL;
	propertyWin* m_propertyWin = NULL;
	MsgBox* m_msgBox = NULL;

	QPushButton* m_minBtn = NULL;
	QPushButton* m_closeBtn = NULL;

	//监控文件夹
	FileMonitorMgr* m_fileMgr;
private:
	void init();
signals:
	void sigCommitReconRequest(const QString& strFilePath);
	void sigInitTree(QStringList fileLst, QString filePath);
	void sigFilterJpg(QStringList jgpFileLst, QString filePath);

protected slots:
	void slotDirectoryChanged(const QString& strDirectory);
	void watchFloder(bool flag);
	void slotShowImgs(QStringList lst, QString path);
private:
	QStringList GetFileNames(const QFileInfoList& fileInfoList);
	QStringList getFolderFiles(const QString& path);
	QStringList fliterJPG(const QString& path);

private:
	QString m_strMonitorDirectory;
	QStringList m_strListFileNames;
	QStringList m_allFile;
	QStringList m_filterJpgImg;
	QFileSystemWatcher* m_pDirectoryWatcher;

	QVector<QString> m_changeFiles;

	QListWidget* m_ImageList;

};


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139

2. 主界面实现界面

#include "QDockWidgetDemo.h"

#include <QDesktopWidget>
#include <QDebug>
#include <QStandardPaths>
#include <QTimer>
#include <QHBoxLayout>
#include <QSpacerItem>
#include <QFileDialog>
#include <QDir>

#pragma execution_character_set("utf-8")

Q_DECLARE_METATYPE(QDockWidget::DockWidgetFeatures)

QString MenuBarStyle =
"QMenuBar{background-color:#FFFFFF; font:14px; color:#232323;}"
"QMenuBar::item{\
        min-height:40px; \
	    margin:1 10 0 10px; \
	    padding:10 10 10 10px; /* 条目内边框 */ \
	    background:#FFFFFF; /* 背景颜色 */ \
	    border-radius:4px; /* 倒角 */ \
    }"
	"QMenuBar::item:selected{background: #E5E5E5; }"
	;

QString MenuStyle =
"QMenu{/*整个背景*/}"
"QMenu::item{ \
	    font-size: 14px; \
	    color: rgb(225,225,225);  /*字体颜色*/\
	    border: 3px solid rgb(60,60,60);    /*item选框*/\
	    background-color:rgb(89,87,87); \
	    padding:16px 16px; /*设置菜单项文字上下和左右的内边距,效果就是菜单中的条目左右上下有了间隔*/\
	    margin:0px 2px;/*设置菜单项的外边距*/\
    }"
	"QMenu::item:selected{background-color:#1E1E1E;/*选中的样式*/}"
	"QMenu::item:pressed{/*菜单项按下效果*/  border: 1px solid rgb(60,60,61); background-color: rgb(220,80,6);}"
	;

QString tabBarStyle =
"QTabBar::tab{min-height: 28px;  min-width:80px ;  font:14px; }"
"QTabBar::tab:!selected{}"
"QTabBar::tab:!selected:hover{ background-color: #d9fffe; color: black;}"
"QToolBar{background-color:#e5e5e5; margin:3px;}"
"QToolBar::separator{height:1px; background-color:#000000;}"
"QToolBar QToolButton{min-width:60px; min-height:40px; background-color:transparent;}"
"QToolBar QToolButton:hover{background-color:rgba(255,255,255,0.8);}"
"QToolBar QToolButton:pressed{background-color:rgba(255,255,255,0.5);}"
;

QDockWidgetDemo::QDockWidgetDemo(QWidget* parent) : QMainWindow(parent)
{
	qRegisterMetaType<QDockWidget::DockWidgetFeatures>();

	ui.setupUi(this);
	this->setWindowTitle(tr("图像处理"));
	this->setWindowIcon(QIcon(":/images/logo.png"));
	this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
	this->setStyleSheet(tabBarStyle);
	//this->setStyleSheet("QMainWindow::separator {width: 2px;height: 2px;margin: 2px;padding: 2,2px;}");

	//On the top menu bar add toolbar,menubar and dockwidget.
	initTitleBar();
	initToolBar();
	initLogView();
	initProjectView();      //项目区初始化在前。
	initWorkSpaceView();	//工作区初始化在后。
	initPropertyView();
	dockLayout();

	initShowImage();   //显示图片

	this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
	//This property holds the tab shape used for tabbed dock widgets.
	this->setTabShape(QTabWidget::Triangular);
	this->statusBar()->showMessage(tr("Status Bar"));

	addLog("框架启动完成,欢迎进入主界面!");

	QTimer::singleShot(2, this, SLOT(s_timeout()));
}

void QDockWidgetDemo::initWorkSpaceView() {
	if (NULL == m_workspace) {
		m_workspace = new QWidget;
		m_workspace->setWindowTitle("工作区");
		this->setCentralWidget(m_workspace);
	}
	qDebug() << "工作区 id:" << m_workspace->winId() << ", name:" << m_workspace->windowTitle();
}

void QDockWidgetDemo::initTitleBar()
{
	QMenuBar* m_MenuBar = this->menuBar();
	m_MenuBar->setStyleSheet(MenuBarStyle);

	QMenu* m_viewMenu = this->menuBar()->addMenu(tr("视图"));
	m_viewMenu->setStyleSheet(MenuStyle);

	m_toolBarAc = new QAction("工具栏");
	connect(m_toolBarAc, &QAction::triggered, this, &QDockWidgetDemo::s_showToolBar);
	m_toolBarAc->setCheckable(true);
	m_toolBarAc->setChecked(true);

	m_projectAc = new QAction("项目");
	connect(m_projectAc, &QAction::triggered, this, &QDockWidgetDemo::s_showPorjectWin);
	m_projectAc->setCheckable(true);
	m_projectAc->setChecked(true);

	m_propertyAc = new QAction("属性");
	connect(m_propertyAc, &QAction::triggered, this, &QDockWidgetDemo::s_showPropertyWin);
	m_propertyAc->setCheckable(true);
	m_propertyAc->setChecked(true);

	m_logAc = new QAction("输出");
	connect(m_logAc, &QAction::triggered, this, &QDockWidgetDemo::s_showLogWin);
	m_logAc->setCheckable(true);
	m_logAc->setChecked(true);

	m_viewMenu->addAction(m_toolBarAc);
	m_viewMenu->addAction(m_projectAc);
	m_viewMenu->addAction(m_propertyAc);
	m_viewMenu->addAction(m_logAc);

	QMenu* m_setView = this->menuBar()->addMenu(tr("编辑"));
	QMenu* m_toolMenu = this-> menuBar()->addMenu(tr("目标识别"));
	QMenu* m_sar = this->menuBar()->addMenu(tr("SAR处理"));
	QMenu* m_picture = this->menuBar()->addMenu(tr("图像"));
	QMenu* m_helpMenu = this->menuBar()->addMenu(tr("帮助"));

	//connect(m_setView, SIGNAL(triggered(QAction*)), this, SLOT(s_monitorFile(QAction*)));
	connect(m_setView, SIGNAL(triggered(QAction*)), this, SLOT(s_monitorFile(QAction*)));
	//connect(m_setView, &QMenu::triggered, this, &QDockWidgetDemo::s_monitorFile);

	initMaxMinWin();
 }

void QDockWidgetDemo::initMaxMinWin() {
	m_maxminWin = new QWidget(this);

	QHBoxLayout* horizontalLayout;
	QSpacerItem* horizontalSpacer;

	horizontalLayout = new QHBoxLayout(m_maxminWin);
	horizontalLayout->setSpacing(0);
	horizontalLayout->setContentsMargins(11, 11, 11, 11);
	horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
	horizontalLayout->setContentsMargins(0, 0, 0, 0);

	horizontalSpacer = new QSpacerItem(241, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

	m_minBtn = new QPushButton(m_maxminWin);
	connect(m_minBtn, &QPushButton::clicked, this, &QDockWidgetDemo::s_min);
	m_minBtn->setObjectName(QString::fromUtf8("minBtn"));
	m_minBtn->setMinimumSize(QSize(40, 40));
	m_minBtn->setMaximumSize(QSize(40, 40));
	m_minBtn->setStyleSheet(QString::fromUtf8("QPushButton{border:none;}\n"
		"QPushButton::hover{background-color:#E5E5E5;}\n"
	""));
	QIcon icon;
	icon.addFile(QString::fromUtf8(":/images/min_main.png"), QSize(), QIcon::Normal, QIcon::Off);
	m_minBtn->setIcon(icon);
	m_minBtn->setIconSize(QSize(25, 25));
	m_minBtn->setAutoDefault(false);
	m_minBtn->setFlat(false);
	m_minBtn->setDefault(false);

	m_closeBtn = new QPushButton(m_maxminWin);
	connect(m_closeBtn, &QPushButton::clicked, this, &QDockWidgetDemo::s_close);
	m_closeBtn->setObjectName(QString::fromUtf8("closeBtn"));
	m_closeBtn->setMinimumSize(QSize(40, 40));
	m_closeBtn->setMaximumSize(QSize(40, 40));
	m_closeBtn->setStyleSheet(QString::fromUtf8("QPushButton{border:none;}\n"
		"QPushButton::hover{background-color:#E81123;}\n"
	));
	QIcon icon1;
	icon1.addFile(QString::fromUtf8(":/images/close_release.png"), QSize(), QIcon::Normal, QIcon::Off);
	m_closeBtn->setIcon(icon1);
	m_closeBtn->setIconSize(QSize(20, 20));
	m_closeBtn->setFlat(false);

	horizontalLayout->addItem(horizontalSpacer);
	horizontalLayout->addWidget(m_minBtn);
	horizontalLayout->addWidget(m_closeBtn);
	horizontalLayout->setStretch(0, 1);

	m_maxminWin->setLayout(horizontalLayout);
	this->menuBar()->setCornerWidget(m_maxminWin, Qt::TopRightCorner);
}

void QDockWidgetDemo::initShowImage()
{
	m_ImageList = new QListWidget(m_workspace);
	m_ImageList->resize(2150, 1080);
	m_ImageList->setViewMode(QListWidget::IconMode);  //显示模式
	
	m_ImageList->setIconSize(QSize(400, 320));//设置图片大小
	m_ImageList->setSpacing(0);//间距
	//m_ImageList->setResizeMode(QListWidget::Adjust); //适应布局调整
	m_ImageList->setMovement(QListWidget::Free); //可移动,static:不可移动
	m_ImageList->setDragDropMode(QAbstractItemView::InternalMove);  //可拖拽
	m_ImageList->setWrapping(true);  //自动换行
	m_ImageList->setFlow(QListWidget::TopToBottom);  //从上到下   LeftToRight从左到右布局

	/*QGridLayout* grid = new QGridLayout;
	grid->addWidget(m_ImageList);
	this->setLayout(grid);*/

	m_ImageList->setHidden(true);
	
}

void QDockWidgetDemo::QDockWidgetDemo::s_showToolBar() {
	if (m_toolBarAc->isChecked()) {
		ui.mainToolBar->show();
		addLog("显示 工具栏");
	}
	else {
		ui.mainToolBar->hide();
		addLog("隐藏 工具栏");
	}
}

void QDockWidgetDemo::QDockWidgetDemo::s_showPorjectWin() {
	if (m_projectAc->isChecked()) {
		m_projManagerView->show();
		addLog("显示 项目区");
	}
	else {
		m_projManagerView->hide();
		addLog("隐藏 项目区");
	}
}

void QDockWidgetDemo::QDockWidgetDemo::s_showPropertyWin() {
	if (m_propertyAc->isChecked()) {
		m_propertyView->show();
		addLog("显示 属性区");
	}
	else {
		m_propertyView->hide();
		addLog("隐藏 属性区");
	}
}

void QDockWidgetDemo::QDockWidgetDemo::s_showLogWin() {
	if (m_logAc->isChecked()) {
		m_logView->show();
		addLog("显示 日志区");
	}
	else {
		m_logView->hide();
		addLog("隐藏 日志区");
	}
}

void QDockWidgetDemo::QDockWidgetDemo::s_timeout() {
	this->showMaximized();
}

void QDockWidgetDemo::QDockWidgetDemo::s_close() {
	this->close();
}

void QDockWidgetDemo::QDockWidgetDemo::s_min() {
	this->showMinimized();
}

void QDockWidgetDemo::addLog(const QString& log)
{
	m_logBody->setReadOnly(true);
	m_logBody->append(log);
}

void QDockWidgetDemo::s_monitorFile()
{
	qDebug() << tr("文件夹监控中");
}

void QDockWidgetDemo::initLogView() {
	if (NULL == m_logView) {
		m_logView = new QDockWidget(this);
		//set dock widget feature: not move, enable close.
		m_logView->setFeatures(QDockWidget::DockWidgetClosable);
		m_logView->setWindowTitle("输出");

		m_logBody = new QTextEdit(this);
		m_logView->setWidget(m_logBody);
	}

	QPalette pl = m_logBody->palette();
	pl.setBrush(QPalette::Base, QBrush(QColor(255, 0, 0, 0)));
	m_logBody->setPalette(pl);
}

void QDockWidgetDemo::initPropertyView() {
	if (NULL == m_propertyView) {
		m_propertyView = new QDockWidget(this);
		m_propertyView->setFeatures(QDockWidget::DockWidgetClosable);
		m_propertyView->setWindowTitle("飞行参数");

		m_propertyWin = new propertyWin(this);
		m_propertyView->setWidget(m_propertyWin);
		qDebug() << "属性区 id:" << m_propertyView->winId() << ", name:" << m_propertyView->windowTitle();
	}
}

void QDockWidgetDemo::initProjectView() {
	if (NULL == m_projManagerView) {
		m_projManagerView = new QDockWidget(this);
		m_projManagerView->setFeatures(QDockWidget::DockWidgetClosable);
		m_projManagerView->setWindowTitle("图像列表");
		
		delete title bar
		//QWidget* lTitleBar = m_projManagerView->titleBarWidget();
		//QWidget* lEmptyWidget = new QWidget();
		//m_projManagerView->setTitleBarWidget(lEmptyWidget);
		//delete lTitleBar;

		m_projectWin = new projectWin(this);
		m_projManagerView->setWidget(m_projectWin);

		qDebug() << "项目区 id:" << m_projManagerView->winId() << ", name:" << m_projManagerView->windowTitle();

		connect(this, &QDockWidgetDemo::sigInitTree, m_projectWin, &projectWin::slotTree);
		connect(this, &QDockWidgetDemo::sigFilterJpg, this, &QDockWidgetDemo::slotShowImgs);
	}
}

void QDockWidgetDemo::dockLayout() {
	this->addDockWidget(Qt::LeftDockWidgetArea, m_projManagerView, Qt::Orientation::Vertical);
	this->addDockWidget(Qt::RightDockWidgetArea, m_propertyView, Qt::Orientation::Vertical);
	this->addDockWidget(Qt::BottomDockWidgetArea, m_logView, Qt::Orientation::Vertical);
}

void QDockWidgetDemo::initToolBar() {
	QSize toolIconSize(50, 30);
	ui.mainToolBar->setIconSize(toolIconSize);   //设置工具栏图标大小

	QIcon newFileIcon(":/images/新建文件.png");
	QIcon openFileIcon(":/images/打开文件.png");
	QIcon saveFileIcon(":/images/保存.png");
	QIcon runIcon(":/images/运行.png");
	QIcon stopIcon(":/images/停止.png");
	QIcon debugIcon(":/images/调试.png");
	QIcon anaysisIcon(":/images/分析.png");
	QIcon recordIcon(":/images/录制.png");
	QIcon grabIcon(":/images/抓取.png");
	QIcon capacityIcon(":/images/应用中心.png");
	QIcon paramterIcon(":/images/参数.png");
	QIcon publishIcon(":/images/发布.png");
	QIcon exportIcon(":/images/导出.png");

	m_newAc = new QAction(newFileIcon, "新建项目", this);
	m_saveAc = new QAction(saveFileIcon, "保存", this);
	m_runAc = new QAction(runIcon, "运行", this);
	m_stopAc = new QAction(stopIcon, "停止", this);
	m_debugAc = new QAction(debugIcon, "调试", this);
	m_anaysisAc = new QAction(anaysisIcon, "分析", this);
	m_recordAc = new QAction(recordIcon, "录制", this);
	m_grabAc = new QAction(grabIcon, "抓取", this);
	m_capacityAc = new QAction(capacityIcon, "能力中心", this);
	m_paramterAc = new QAction(paramterIcon, "参数", this);
	m_publishAc = new QAction(publishIcon, "发布", this);
	m_exportAc = new QAction(exportIcon, "导出", this);

	//add QAction to Widget.
	ui.mainToolBar->addAction(m_newAc);
	ui.mainToolBar->addAction(m_saveAc);
	ui.mainToolBar->addAction(m_saveAc);
	ui.mainToolBar->addSeparator();
	ui.mainToolBar->addAction(m_runAc);
	ui.mainToolBar->addAction(m_stopAc);
	ui.mainToolBar->addAction(m_debugAc);
	ui.mainToolBar->addAction(m_anaysisAc);
	ui.mainToolBar->addSeparator();
	ui.mainToolBar->addAction(m_recordAc);
	ui.mainToolBar->addAction(m_grabAc);
	ui.mainToolBar->addSeparator();
	ui.mainToolBar->addAction(m_capacityAc);
	ui.mainToolBar->addSeparator();
	ui.mainToolBar->addAction(m_paramterAc);
	ui.mainToolBar->addAction(m_publishAc);
	ui.mainToolBar->addAction(m_exportAc);
	ui.mainToolBar->addSeparator();

	connect(m_newAc, &QAction::triggered, this, &QDockWidgetDemo::s_MonitorFolder);
	connect(m_saveAc, &QAction::triggered, this, &QDockWidgetDemo::s_saveFile);
	connect(m_runAc, &QAction::triggered, this, &QDockWidgetDemo::s_runAc);
	connect(m_stopAc, &QAction::triggered, this, &QDockWidgetDemo::s_stopAc);
	connect(m_debugAc, &QAction::triggered, this, &QDockWidgetDemo::s_debugAc);
	connect(m_anaysisAc, &QAction::triggered, this, &QDockWidgetDemo::s_anaysisAc);
	connect(m_recordAc, &QAction::triggered, this, &QDockWidgetDemo::s_recordAc);
	connect(m_grabAc, &QAction::triggered, this, &QDockWidgetDemo::s_grabAc);
	connect(m_capacityAc, &QAction::triggered, this, &QDockWidgetDemo::s_capacityAc);
	connect(m_paramterAc, &QAction::triggered, this, &QDockWidgetDemo::s_paramterAc);
	connect(m_publishAc, &QAction::triggered, this, &QDockWidgetDemo::s_publishAc);
	connect(m_exportAc, &QAction::triggered, this, &QDockWidgetDemo::s_exportAc);
}

void QDockWidgetDemo::QDockWidgetDemo::s_hideProj() {
	m_projectAc->setChecked(false);
	m_projManagerView->hide();
}

void QDockWidgetDemo::QDockWidgetDemo::s_propertyWinHide(bool visible) {
	if (!visible) {
		m_propertyAc->setChecked(false);
		m_propertyView->hide();
	}
}

void QDockWidgetDemo::QDockWidgetDemo::s_logWinHide(bool visible) {
	if (!visible) {
		m_logAc->setChecked(false);
		m_logView->hide();
	}
}

void QDockWidgetDemo::s_MonitorFolder() {

	m_strMonitorDirectory = QFileDialog::getExistingDirectory(this, tr("请选择共享文件夹"), "./");
	QString monitorFolder = tr("开始监控文件夹:") + m_strMonitorDirectory;
	addLog(monitorFolder);
	m_allFile = getFolderFiles(m_strMonitorDirectory);
	m_filterJpgImg = fliterJPG(m_strMonitorDirectory);

	emit sigInitTree(m_allFile, m_strMonitorDirectory);
	emit sigFilterJpg(m_filterJpgImg, m_strMonitorDirectory);
}
void QDockWidgetDemo::s_saveFile() {
	QString log = QString("功能正在开发中,请耐心等待!");
	showMessageBox(log);
	addLog(log);
}
void QDockWidgetDemo::s_runAc() {
	QString log = QString("功能正在开发中,请耐心等待!");
	showMessageBox(log);
	addLog(log);
}
void QDockWidgetDemo::s_stopAc() {
	QString log = QString("功能正在开发中,请耐心等待!");
	showMessageBox(log);
	addLog(log);
}
void QDockWidgetDemo::s_debugAc() {
	QString log = QString("功能正在开发中,请耐心等待!");
	showMessageBox(log);
	addLog(log);
}
void QDockWidgetDemo::s_anaysisAc() {
	QString log = QString("功能正在开发中,请耐心等待!");
	showMessageBox(log);
	addLog(log);
}
void QDockWidgetDemo::s_recordAc() {
	QString log = QString("功能正在开发中,请耐心等待!");
	showMessageBox(log);
	addLog(log);
}
void QDockWidgetDemo::s_grabAc() {
	QString log = QString("功能正在开发中,请耐心等待!");
	showMessageBox(log);
	addLog(log);
}
void QDockWidgetDemo::s_capacityAc() {
	QString log = QString("功能正在开发中,请耐心等待!");
	showMessageBox(log);
	addLog(log);
}
void QDockWidgetDemo::s_paramterAc() {
	QString log = QString("功能正在开发中,请耐心等待!");
	showMessageBox(log);
	addLog(log);
}
void QDockWidgetDemo::s_publishAc() {
	QString log = QString("功能正在开发中,请耐心等待!");
	showMessageBox(log);
	addLog(log);
}
void QDockWidgetDemo::s_exportAc() {
	QString log = QString("功能正在开发中,请耐心等待!");
	showMessageBox(log);
	addLog(log);
}

void QDockWidgetDemo::showMessageBox(const QString& text) {
	if (NULL == m_msgBox) {
		m_msgBox = new MsgBox();
	}

	m_msgBox->setMsgText(text);
	m_msgBox->show();
}


void QDockWidgetDemo::init()
{
	m_changeFiles.clear();
	m_strListFileNames.clear();
	QString filePath = "F:\\QtExercise\\FileMonitorMgr\\Test";
	m_strListFileNames = QDir(filePath).entryList();
	m_strMonitorDirectory = filePath;

	m_pDirectoryWatcher = new QFileSystemWatcher(this);
	m_pDirectoryWatcher->addPath(filePath);

	connect(m_pDirectoryWatcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(slotDirectoryChanged(const QString&)));


	//connect(ui->pushButton, SIGNAL(clicked(bool)), this, SLOT(watchFloder(bool)));
}

//QVector<QString> &MainWindow::getFileName()
//{
//    return m_fileNameVec;
//}

void QDockWidgetDemo::slotDirectoryChanged(const QString& strDirectory)
{
	m_changeFiles.clear();
	QStringList strListFileNames; //To save new file names
	QFileInfoList fileInfoList = QDir(m_strMonitorDirectory).entryInfoList();

	for (int n = 0; n < fileInfoList.size(); n++)
	{
		QFileInfo fileInfo = fileInfoList[n];
		if (fileInfo.fileName().compare(".") == 0 || fileInfo.fileName().compare("..") == 0)
			continue;

		if (fileInfo.isDir())
			continue;

		QString strFileName = fileInfo.fileName();
		if (!m_strListFileNames.contains(strFileName))
		{

			strListFileNames << strFileName;

			//ui->textEdit->append(strFileName);

			m_changeFiles.push_back(strFileName);
		}
	}

	if (strListFileNames.isEmpty())
	{
		m_strListFileNames.clear();
		m_strListFileNames = GetFileNames(fileInfoList);
		return;
	}

	for (int n = 0; n < strListFileNames.size(); n++)
	{
		//commit recon request
		QString strFilePath = m_strMonitorDirectory + "/" + strListFileNames[n];
		emit sigCommitReconRequest(strFilePath);
	}

	m_strListFileNames.clear();
	m_strListFileNames = GetFileNames(fileInfoList);

	for (int i = 0; i < m_changeFiles.size(); i++)
		//显示变化的文件名
		//ui->textEdit->append(m_changeFiles.at(i));

	return;
}

void QDockWidgetDemo::watchFloder(bool flag)
{
	QString filePath = QFileDialog::getExistingDirectory(this, QStringLiteral("请选择共享文件夹"), "./");
	//显示监视的文件路径
	//ui->lineEdit->setText(filePath);

	//    m_strListFileNames.clear();
	//    m_strListFileNames = QDir(filePath).entryList();
	//    m_strMonitorDirectory = filePath;

	//    m_pDirectoryWatcher = new QFileSystemWatcher( this );
	//    m_pDirectoryWatcher->addPath( filePath );

	//    connect( m_pDirectoryWatcher, SIGNAL( directoryChanged( const QString& ) ), this, SLOT( slotDirectoryChanged( const QString& ) ) );
}

void QDockWidgetDemo::slotShowImgs(QStringList lst, QString path)
{
	
	QString allPath = path + "/";
	for (int i = 0; i < lst.size(); i++)
	{
		QString onlyFile = lst.at(i);
		int pos = onlyFile.lastIndexOf("/");
		onlyFile = lst.at(i).right(lst.at(i).size() - pos - 1);
		QListWidgetItem* imageItem = new QListWidgetItem(/*m_ImageList*/);
		QString allImgFiles = allPath + lst.at(i);

		/*QPixmap pPhoto;
		pPhoto.loadFromData(QByteArray(), "jpg");
		QIcon ico;
		ico.addPixmap(pPhoto);*/

		imageItem->setIcon(QIcon(lst.at(i)));
		//imageItem->setText(onlyFile);
		imageItem->setSizeHint(QSize(190, 150));
		m_ImageList->addItem(imageItem);	
		//m_ImageList->setItemWidget(imageItem, this);
	}

	/*QGridLayout* grid = new QGridLayout;
	grid->addWidget(m_ImageList);
	this->setLayout(grid);*/
	m_ImageList->setHidden(false);
}

QStringList QDockWidgetDemo::GetFileNames(const QFileInfoList& fileInfoList)
{
	QStringList strLstNames;
	int nFileNum = fileInfoList.size();
	for (int n = 0; n < nFileNum; n++)
	{
		QFileInfo fileInfo = fileInfoList[n];
		strLstNames << fileInfo.fileName();
	}
	return strLstNames;
}

QStringList QDockWidgetDemo::getFolderFiles(const QString& path)
{
	QDir dir(path);
	QStringList tempList;
	QFileInfoList fileList = dir.entryInfoList(QDir::Files | QDir::AllDirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
	foreach(QFileInfo fileInfo, fileList)
	{
		if (fileInfo.isDir())
		{
			getFolderFiles(fileInfo.absoluteFilePath());
		}
		else
		{
			tempList.append(fileInfo.absoluteFilePath());
		}		
	}

	return tempList;
}

QStringList QDockWidgetDemo::fliterJPG(const QString& path)
{
	QDir dir(path);
	QStringList tempList;
	QStringList filterJpgFiles;
	QFileInfoList fileList = dir.entryInfoList(QDir::Files | QDir::AllDirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
	foreach(QFileInfo fileInfo, fileList)
	{
		if (fileInfo.isDir())
		{
			getFolderFiles(fileInfo.absoluteFilePath());
		}
		else
		{
			tempList.append(fileInfo.absoluteFilePath());
		}
	}

	foreach(QString item, tempList)
	{
		if (item.contains(".jpg"))
		{
			filterJpgFiles.append(item);
		}		
	}

	return filterJpgFiles;
}




  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476
  • 477
  • 478
  • 479
  • 480
  • 481
  • 482
  • 483
  • 484
  • 485
  • 486
  • 487
  • 488
  • 489
  • 490
  • 491
  • 492
  • 493
  • 494
  • 495
  • 496
  • 497
  • 498
  • 499
  • 500
  • 501
  • 502
  • 503
  • 504
  • 505
  • 506
  • 507
  • 508
  • 509
  • 510
  • 511
  • 512
  • 513
  • 514
  • 515
  • 516
  • 517
  • 518
  • 519
  • 520
  • 521
  • 522
  • 523
  • 524
  • 525
  • 526
  • 527
  • 528
  • 529
  • 530
  • 531
  • 532
  • 533
  • 534
  • 535
  • 536
  • 537
  • 538
  • 539
  • 540
  • 541
  • 542
  • 543
  • 544
  • 545
  • 546
  • 547
  • 548
  • 549
  • 550
  • 551
  • 552
  • 553
  • 554
  • 555
  • 556
  • 557
  • 558
  • 559
  • 560
  • 561
  • 562
  • 563
  • 564
  • 565
  • 566
  • 567
  • 568
  • 569
  • 570
  • 571
  • 572
  • 573
  • 574
  • 575
  • 576
  • 577
  • 578
  • 579
  • 580
  • 581
  • 582
  • 583
  • 584
  • 585
  • 586
  • 587
  • 588
  • 589
  • 590
  • 591
  • 592
  • 593
  • 594
  • 595
  • 596
  • 597
  • 598
  • 599
  • 600
  • 601
  • 602
  • 603
  • 604
  • 605
  • 606
  • 607
  • 608
  • 609
  • 610
  • 611
  • 612
  • 613
  • 614
  • 615
  • 616
  • 617
  • 618
  • 619
  • 620
  • 621
  • 622
  • 623
  • 624
  • 625
  • 626
  • 627
  • 628
  • 629
  • 630
  • 631
  • 632
  • 633
  • 634
  • 635
  • 636
  • 637
  • 638
  • 639
  • 640
  • 641
  • 642
  • 643
  • 644
  • 645
  • 646
  • 647
  • 648
  • 649
  • 650
  • 651
  • 652
  • 653
  • 654
  • 655
  • 656
  • 657
  • 658
  • 659
  • 660
  • 661
  • 662
  • 663
  • 664
  • 665
  • 666
  • 667
  • 668
  • 669
  • 670
  • 671
  • 672
  • 673
  • 674
  • 675
  • 676
  • 677
  • 678
  • 679
  • 680
  • 681

2.左边图片目录展示界面

1.图片目录头文件

#pragma once

#include <QWidget>
#include <QTreeWidget>
#include <QFileSystemWatcher>
#include <QListWidget>
#include "FileMonitorMgr.h"
#include "ui_projectWin.h"

class QFileSystemWatcher;

class projectWin : public QWidget
{
	Q_OBJECT

public:
	projectWin(QWidget* parent = Q_NULLPTR);
	~projectWin();
public:
	FileMonitorMgr *m_fileMgr;
	void showImgList(QStringList& imgList);

private:
	void initWidget();
	void initTree();

public Q_SLOTS:
	void slotClicked(QTreeWidget* item, int column);
	void slotMenuPup(const QPoint* point);
	void slotTree(QStringList lst, QString path);
	//void slotShowImgs(QStringList lst, QString path);

private:
	Ui::projectWin ui;

	QTreeWidget* m_tree;
	QMenu* m_menu;

	//QListWidget* m_ImageList;

};

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

2.图片目录实现文件

#include "projectWin.h"

#include <QStandardPaths>
#include <QDir>
#include <QDebug>
#include <QVBoxLayout>
#include <QGridLayout>


#pragma execution_character_set("utf-8")

const QString styles = "QTreeView\
{\
    background-color: #5B677A;\
    font-size:17px;\
    color: white;\
}\
QTreeView::item:hover\
{\
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);\
    border: 1px solid #bfcde4;\
}\
QTreeView::item:hover\
{\
    background: rgb(69, 187, 217);\
}\
QTreeView::item:selected:active\
{\
    background: rgb(255, 62, 150);\
}\
QTreeView::item:selected:!active\
{\
    background: rgb(63, 147, 168);\
}\
QTreeView::branch\
{\
    background:#5B677A;\
}\
QTreeView::branch:has-children:!has-siblings:closed,QTreeView::branch:closed:has-children:has-siblings\
{\
    border-image: none;\
    background:#5B677A;\
    image: url(image/Folder-1.png);\
}\
QTreeView::branch:open:has-children:!has-siblings,QTreeView::branch:open:has-children:has-siblings\
{\
    border-image: none;\
    background:#5B677A;\
    image: url(image/Open-Folder.png);\
}";



projectWin::projectWin(QWidget* parent) : QWidget(parent)
{
	ui.setupUi(this);

	initWidget();
}

projectWin::~projectWin() {}

void projectWin::showImgList(QStringList& imgList)
{

}

void projectWin::initWidget() 
{
	//m_ImageList = new QListWidget;
	m_ImageList->setViewMode(QListWidget::IconMode);  //显示模式
	//
	m_ImageList->setIconSize(QSize(100, 100));//设置图片大小
	//m_ImageList->setSpacing(1);//间距
	//m_ImageList->setResizeMode(QListWidget::Adjust); //适应布局调整
	//m_ImageList->setMovement(QListWidget::Free); //可移动,static:不可移动
	//m_ImageList->setWrapping(true);  //自动换行
	//m_ImageList->setFlow(QListWidget::LeftToRight);  //从左到右布局

}

void projectWin::initTree()
{
	//m_fileMgr = new FileMonitorMgr("F:/QtExercise/QDockWidgetDemo/QDockWidgetDemo/Monitor");
	//m_tree = new QTreeWidget();
	打开右键菜单属性
	//m_tree->setContextMenuPolicy(Qt::CustomContextMenu);

	添加顶层节点
	//if (m_fileMgr->m_allFileList.size() > 0)
	//{
	//	int count = m_fileMgr->m_allFileList.size();
	//	for (int i = 0; i < count; i++)
	//	{
	//		QTreeWidgetItem* topItem = new QTreeWidgetItem(m_tree);
	//		topItem->setText(i, m_fileMgr->m_allFileList.at(i));
	//		topItem->setCheckState(i, Qt::Checked);
	//		m_tree->addTopLevelItem(topItem);
	//	}
	//}

	//m_tree->expandAll();
	//m_tree->setStyleSheet(styles);
}

void projectWin::slotClicked(QTreeWidget* item, int column)
{

}

void projectWin::slotMenuPup(const QPoint* point)
{

}

void projectWin::slotTree(QStringList lst, QString path)
{
	//m_fileMgr = new FileMonitorMgr("F:/QtExercise/QDockWidgetDemo/QDockWidgetDemo/Monitor");
	m_tree = new QTreeWidget();
	//打开右键菜单属性
	m_tree->setContextMenuPolicy(Qt::CustomContextMenu);

	QTreeWidgetItem* topItem = new QTreeWidgetItem(m_tree);
	topItem->setText(0, path);
	topItem->setCheckState(0, Qt::Checked);
	m_tree->addTopLevelItem(topItem);
	int count = lst.size();
	//添加顶层节点
	if (lst.size() > 0)
	{
		for (int i = 0; i < lst.size(); i++)
		{
			int size = lst.at(i).size();
			int pos = lst.at(i).lastIndexOf("/");
			QString temp = lst.at(i).right(size - pos - 1);
			QTreeWidgetItem* item = new QTreeWidgetItem(topItem);
			item->setText(0, temp);
			item->setCheckState(0, Qt::Checked);
		}
	}

	QVBoxLayout* layout = new QVBoxLayout();
	m_tree->expandAll();
	m_tree->setStyleSheet(styles);
	layout->addWidget(m_tree);
	this->setLayout(layout);
}

//void projectWin::slotShowImgs(QStringList lst, QString path)
//{
//	QString allPath = path + "/";
//	for (int i=0; i<lst.size(); i++)
//	{
//		QListWidgetItem* imageItem = new QListWidgetItem;
//		QString allImgFiles = allPath + lst.at(i);
//		imageItem->setIcon(QIcon(lst.at(i)));
//		imageItem->setText(lst.at(i));
//		imageItem->setSizeHint(QSize(120, 100));
//		m_ImageList->addItem(imageItem);
//	}	
//
//	QGridLayout* grid = new QGridLayout;
//	grid->addWidget(m_ImageList);
//	this->setLayout(grid);
//}


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167

2.属性窗口区

1.属性窗口头文件

#pragma once

#include <QWidget>

#include "ui_propertyWin.h"

class propertyWin : public QWidget
{
	Q_OBJECT

public:
	propertyWin(QWidget* parent = Q_NULLPTR);
	~propertyWin();

private:
	void initWidget();

private:
	Ui::propertyWin ui;
};

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

2.属性窗口实现文件

#include "propertyWin.h"

#include <QStandardPaths>
#include <QDir>
#include <QDebug>

#pragma execution_character_set("utf-8")

propertyWin::propertyWin(QWidget* parent) : QWidget(parent)
{
	ui.setupUi(this);

	initWidget();
}

propertyWin::~propertyWin() {}

void propertyWin::initWidget() {}



  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

3 源码下载

源码下载地址

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/764772
推荐阅读
相关标签
  

闽ICP备14008679号