Skip to content

Commit

Permalink
a simple cmake-qt demo with out doxygen.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yue-Lan committed May 27, 2019
1 parent 6252050 commit 5db3b86
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.8)

project(demo)

find_package(Qt5 ${QT_MINIMUM_VERSION} REQUIRED COMPONENTS Core Widgets)

set(CMAKE_AUTOMOC TRUE)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_subdirectory(src)

5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
aux_source_directory(. DIR_SRCS)
add_executable(demo ${DIR_SRCS})

target_link_libraries(${PROJECT_NAME} Qt5::Widgets)

11 changes: 11 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <QApplication>
#include "mylistview.h"

int main (int argc, char *argv[]) {
QApplication a(argc, argv);

MyListView *view = new MyListView;
view->show ();

return a.exec();
}
5 changes: 5 additions & 0 deletions src/mylistmodel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "mylistmodel.h"

MyListModel::MyListModel (){
this->setRootPath("/usr/share");
}
11 changes: 11 additions & 0 deletions src/mylistmodel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef MY_LIST_MODEL_H
#define MY_LIST_MODEL_H

#include <QFileSystemModel>

class MyListModel : public QFileSystemModel {
public:
MyListModel ();
};

#endif
11 changes: 11 additions & 0 deletions src/mylistview.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "mylistview.h"

MyListView::MyListView () {
this->model = new MyListModel;
this->setModel (this->model);
this->setRootIndex (this->model->index (this->model->rootPath()));
}

MyListView::~MyListView () {
delete this->model;
}
16 changes: 16 additions & 0 deletions src/mylistview.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef MY_LIST_VIEW_H
#define MY_LIST_VIEW_H

#include <QListView>
#include "mylistmodel.h"

class MyListView : public QListView {
public:
MyListView ();
~MyListView ();

private:
MyListModel *model;
};

#endif

0 comments on commit 5db3b86

Please sign in to comment.