-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
34 lines (30 loc) · 1.15 KB
/
mainwindow.cpp
File metadata and controls
34 lines (30 loc) · 1.15 KB
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
/**
* example code to complete my answer to my question on StackOverflow: see
* http://stackoverflow.com/questions/19232882/nice-text-formatting-in-qtextedit-like-qtcreator-does
* author: CapelliC @2015
* license: MIT
*/
#include "mainwindow.h"
#include "file2string.h"
#include "foldingQTextEdit.h"
#include <QToolBar>
#include <QAction>
/**
* @brief MainWindow::MainWindow
* sample setup for easy debug: open an editor on this same file
* assume running in Debug folder of 'Projects/build/Shadow build'
* @param parent
* Qt standard boilerplate
*/
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
auto w = new foldingQTextEdit;
w->setPlainText(file2string("../foldingQTextEdit/mainwindow.cpp"));
setCentralWidget(w);
auto toolbar = addToolBar("test");
connect(toolbar->addAction("fold"), &QAction::triggered, w, &foldingQTextEdit::fold);
connect(toolbar->addAction("unfold"), &QAction::triggered, w, &foldingQTextEdit::unfold);
connect(toolbar->addAction("frame"), &QAction::triggered, w, &foldingQTextEdit::frame);
connect(toolbar->addAction("unframe"), &QAction::triggered, w, &foldingQTextEdit::unframe);
}