[cpp] Add Qt Desginer widget plugin examples
This commit is contained in:
36
cpp/qt/designer-plugin-collection/treeview.h
Normal file
36
cpp/qt/designer-plugin-collection/treeview.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*##############################################################################
|
||||
## Author: Shaun Reed ##
|
||||
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
||||
## About: Tree viewer ##
|
||||
## ##
|
||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||
################################################################################
|
||||
*/
|
||||
|
||||
#ifndef KLIPS_TREEVIEW_H
|
||||
#define KLIPS_TREEVIEW_H
|
||||
|
||||
#include "widget-plugin-library_export.h"
|
||||
#include <app-dir.h>
|
||||
|
||||
#include <QFileSystemModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QTreeView>
|
||||
|
||||
class WIDGET_PLUGIN_LIBRARY_EXPORT TreeView : public QTreeView {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TreeView(QWidget *parent = nullptr) : QTreeView(parent) {
|
||||
QFileSystemModel *model = new QFileSystemModel;
|
||||
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
|
||||
QModelIndex rootModelIndex = model->setRootPath(APP_DIR);
|
||||
proxy->setSourceModel(model);
|
||||
setModel(proxy);
|
||||
setRootIndex(proxy->mapFromSource(rootModelIndex));
|
||||
}
|
||||
|
||||
~TreeView() = default;
|
||||
};
|
||||
|
||||
#endif // KLIPS_TREEVIEW_H
|
||||
Reference in New Issue
Block a user