-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.cpp
47 lines (38 loc) · 1.38 KB
/
mainwindow.cpp
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
#include "mainwindow.h"
#include <QtWidgets/QApplication>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QVBoxLayout>
#include <QtGui/QIcon>
#include <QtCore/QDebug>
#include <QtCore/QTextStream>
static const char defaultScript[] =
"print(\"Hello, world\")\n"
"mainWindow.testFunction1()\n";
MainWindow::MainWindow()
{
setWindowTitle("FooPy MainWindow");
setMinimumSize(400, 260);
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
const QIcon quitIcon = QIcon::fromTheme(QStringLiteral("application-exit"));
QAction *quitAction = fileMenu->addAction(quitIcon, tr("&Quit"), qApp, &QCoreApplication::quit);
quitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
const QIcon aboutIcon = QIcon::fromTheme(QStringLiteral("help-about"));
QAction *aboutAction = helpMenu->addAction(aboutIcon, tr("&About Qt"), qApp, &QApplication::aboutQt);
QToolBar *toolBar = new QToolBar;
addToolBar(toolBar);
toolBar->addAction(quitAction);
toolBar->addSeparator();
toolBar->addAction(aboutAction);
}
void MainWindow::testFunction1()
{
static int n = 1;
QString message;
QTextStream(&message) << __FUNCTION__ << " called #" << n++;
qDebug().noquote() << message;
statusBar()->showMessage(message);
}