No ui file, just C++
parent
d813962046
commit
f2972199de
|
@ -6,6 +6,9 @@
|
|||
"qdir": "cpp",
|
||||
"qfile": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"qmainwindow": "cpp"
|
||||
"qmainwindow": "cpp",
|
||||
"qtextedit": "cpp",
|
||||
"new": "cpp",
|
||||
"qvboxlayout": "cpp"
|
||||
}
|
||||
}
|
|
@ -30,7 +30,6 @@ set(SOURCES
|
|||
markdown-render.h
|
||||
mainwindow.cc
|
||||
mainwindow.h
|
||||
mainwindow.ui
|
||||
)
|
||||
|
||||
if(ANDROID)
|
||||
|
|
16
src/main.cc
16
src/main.cc
|
@ -1,17 +1,19 @@
|
|||
#include "mainwindow.h"
|
||||
|
||||
#include "markdown-render.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QString>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
MarkdownRender md;
|
||||
|
||||
QString output = QString::fromStdString(md.render());
|
||||
w.setLabel(output);
|
||||
w.show();
|
||||
return a.exec();
|
||||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
MainWindow window;
|
||||
window.setOutput(output);
|
||||
window.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -1,21 +1,34 @@
|
|||
#include "mainwindow.h"
|
||||
#include "./ui_mainwindow.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
#include <QVBoxLayout>
|
||||
#include <QMenuBar>
|
||||
#include <QMainWindow>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QSizePolicy>
|
||||
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
resize(600, 400);
|
||||
setWindowTitle("Browser");
|
||||
|
||||
QMenu *fileMenu = new QMenu("File");
|
||||
fileMenu->addAction("New");
|
||||
fileMenu->addAction("Exit");
|
||||
|
||||
menuBar()->addMenu(fileMenu);
|
||||
|
||||
QWidget *centralWidget = new QWidget;
|
||||
setCentralWidget(centralWidget);
|
||||
QVBoxLayout *layout = new QVBoxLayout(centralWidget);
|
||||
layout->setContentsMargins(5, 5, 5, 5);
|
||||
|
||||
textEdit = new QTextEdit();
|
||||
textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
layout->addWidget(textEdit);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
void MainWindow::setOutput(const QString& text)
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::setLabel(const QString& text)
|
||||
{
|
||||
QLabel *label = findChild<QLabel *>("output");
|
||||
if(label)
|
||||
label->setText(text);
|
||||
textEdit->setText(text);
|
||||
}
|
||||
|
|
|
@ -2,22 +2,26 @@
|
|||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
class QAction;
|
||||
class QTextEdit;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
//! [0]
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
MainWindow();
|
||||
void setOutput(const QString& text);
|
||||
|
||||
//private slots:
|
||||
// void newFile();
|
||||
|
||||
void setLabel(const QString& text);
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QTextEdit *textEdit;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
#endif
|
|
@ -1,48 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Browser</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QLabel" name="output">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>0</y>
|
||||
<width>771</width>
|
||||
<height>291</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Empty</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue