Commit 85d8fe4c authored by roangel's avatar roangel
Browse files

Trying different things with Qt Creator. Next step: drawing rectangle

parent cc9f9c1b
This diff is collapsed.
......@@ -2,8 +2,12 @@
#include "ui_mainguiwindow.h"
#include <QDoubleSpinBox>
#include <QTextEdit>
#include <QString>
#define N_MAX_CRAZYFLIES 20 // protection number
#ifndef DEBUG_GUI
MainGUIWindow::MainGUIWindow(ros::NodeHandle* nodeHandle, /*ros::CallbackQueue *callbackQueue,
ros::Publisher* publisherMotorCommandsGUI,*/
......@@ -16,6 +20,7 @@ MainGUIWindow::MainGUIWindow(ros::NodeHandle* nodeHandle, /*ros::CallbackQueue *
m_isStopButtonActive=false;
m_isCalActive=false;
m_trajectoryType=eTrajCustom;
_init();
}
#else
MainGUIWindow::MainGUIWindow(QWidget *parent) :
......@@ -23,6 +28,7 @@ MainGUIWindow::MainGUIWindow(QWidget *parent) :
ui(new Ui::MainGUIWindow)
{
ui->setupUi(this);
_init();
}
#endif
......@@ -31,6 +37,25 @@ MainGUIWindow::~MainGUIWindow()
delete ui;
}
void MainGUIWindow::_refresh_tabs()
{
ui->tabWidget->clear();
std::string str;
for (int i = 0; i < ui->spinBoxNumCrazyflies->value(); i++)
{
str = "CrazyFly ";
str += std::to_string(i+1);
QString qstr(str.c_str());
ui->tabWidget->addTab(new QWidget(), qstr);
}
}
void MainGUIWindow::_init()
{
ui->spinBoxNumCrazyflies->setMaximum(N_MAX_CRAZYFLIES);
_refresh_tabs();
}
#ifndef DEBUG_GUI
void MainGUIWindow::init()
{
......@@ -903,3 +928,12 @@ void CSetpointQueue::print()
// }
#endif // DEBUG_GUI
void MainGUIWindow::on_spinBoxNumCrazyflies_valueChanged(int arg1)
{
}
void MainGUIWindow::on_spinBoxNumCrazyflies_editingFinished()
{
_refresh_tabs();
}
#ifndef MAINGUIWINDOW_H
#define MAINGUIWINDOW_H
// #define DEBUG_GUI
#define DEBUG_GUI
#include <QMainWindow>
#include <QTimer>
......@@ -126,9 +126,15 @@ private slots:
// void on_buttonStop_2_clicked();
#endif
void on_spinBoxNumCrazyflies_valueChanged(int arg1);
void on_spinBoxNumCrazyflies_editingFinished();
private:
Ui::MainGUIWindow *ui;
void _init();
void _refresh_tabs();
#ifndef DEBUG_GUI
// void refreshScreen();
......
......@@ -18,7 +18,7 @@
<property name="geometry">
<rect>
<x>40</x>
<y>500</y>
<y>510</y>
<width>1171</width>
<height>451</height>
</rect>
......@@ -38,16 +38,12 @@
<height>401</height>
</rect>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</widget>
<widget class="QFrame" name="frame_2">
......@@ -82,6 +78,25 @@
<enum>QFrame::Raised</enum>
</property>
</widget>
<widget class="QSpinBox" name="spinBoxNumCrazyflies">
<property name="geometry">
<rect>
<x>1340</x>
<y>560</y>
<width>47</width>
<height>23</height>
</rect>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="accelerated">
<bool>false</bool>
</property>
<property name="maximum">
<number>6</number>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
......
......@@ -19,8 +19,8 @@
QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_MainGUIWindow_t {
QByteArrayData data[1];
char stringdata0[14];
QByteArrayData data[5];
char stringdata0[97];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
......@@ -29,10 +29,15 @@ struct qt_meta_stringdata_MainGUIWindow_t {
)
static const qt_meta_stringdata_MainGUIWindow_t qt_meta_stringdata_MainGUIWindow = {
{
QT_MOC_LITERAL(0, 0, 13) // "MainGUIWindow"
QT_MOC_LITERAL(0, 0, 13), // "MainGUIWindow"
QT_MOC_LITERAL(1, 14, 36), // "on_spinBoxNumCrazyflies_value..."
QT_MOC_LITERAL(2, 51, 0), // ""
QT_MOC_LITERAL(3, 52, 4), // "arg1"
QT_MOC_LITERAL(4, 57, 39) // "on_spinBoxNumCrazyflies_editi..."
},
"MainGUIWindow"
"MainGUIWindow\0on_spinBoxNumCrazyflies_valueChanged\0"
"\0arg1\0on_spinBoxNumCrazyflies_editingFinished"
};
#undef QT_MOC_LITERAL
......@@ -42,22 +47,35 @@ static const uint qt_meta_data_MainGUIWindow[] = {
7, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
2, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 1, 24, 2, 0x08 /* Private */,
4, 0, 27, 2, 0x08 /* Private */,
// slots: parameters
QMetaType::Void, QMetaType::Int, 3,
QMetaType::Void,
0 // eod
};
void MainGUIWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
if (_c == QMetaObject::InvokeMetaMethod) {
MainGUIWindow *_t = static_cast<MainGUIWindow *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->on_spinBoxNumCrazyflies_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 1: _t->on_spinBoxNumCrazyflies_editingFinished(); break;
default: ;
}
}
}
const QMetaObject MainGUIWindow::staticMetaObject = {
......@@ -84,6 +102,15 @@ int MainGUIWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
_id = QMainWindow::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 2)
qt_static_metacall(this, _c, _id, _a);
_id -= 2;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 2)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 2;
}
return _id;
}
QT_END_MOC_NAMESPACE
......@@ -17,6 +17,7 @@
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QTabWidget>
#include <QtWidgets/QToolBar>
......@@ -30,10 +31,9 @@ public:
QWidget *centralWidget;
QFrame *frame;
QTabWidget *tabWidget;
QWidget *tab;
QWidget *tab_2;
QFrame *frame_2;
QFrame *frame_3;
QSpinBox *spinBoxNumCrazyflies;
QMenuBar *menuBar;
QToolBar *mainToolBar;
QStatusBar *statusBar;
......@@ -47,18 +47,13 @@ public:
centralWidget->setObjectName(QStringLiteral("centralWidget"));
frame = new QFrame(centralWidget);
frame->setObjectName(QStringLiteral("frame"));
frame->setGeometry(QRect(40, 500, 1171, 451));
frame->setGeometry(QRect(40, 510, 1171, 451));
frame->setFrameShape(QFrame::StyledPanel);
frame->setFrameShadow(QFrame::Raised);
tabWidget = new QTabWidget(frame);
tabWidget->setObjectName(QStringLiteral("tabWidget"));
tabWidget->setGeometry(QRect(20, 19, 1131, 401));
tab = new QWidget();
tab->setObjectName(QStringLiteral("tab"));
tabWidget->addTab(tab, QString());
tab_2 = new QWidget();
tab_2->setObjectName(QStringLiteral("tab_2"));
tabWidget->addTab(tab_2, QString());
tabWidget->setLayoutDirection(Qt::LeftToRight);
frame_2 = new QFrame(centralWidget);
frame_2->setObjectName(QStringLiteral("frame_2"));
frame_2->setGeometry(QRect(40, 10, 571, 481));
......@@ -69,6 +64,12 @@ public:
frame_3->setGeometry(QRect(630, 10, 791, 481));
frame_3->setFrameShape(QFrame::StyledPanel);
frame_3->setFrameShadow(QFrame::Raised);
spinBoxNumCrazyflies = new QSpinBox(centralWidget);
spinBoxNumCrazyflies->setObjectName(QStringLiteral("spinBoxNumCrazyflies"));
spinBoxNumCrazyflies->setGeometry(QRect(1340, 560, 47, 23));
spinBoxNumCrazyflies->setReadOnly(false);
spinBoxNumCrazyflies->setAccelerated(false);
spinBoxNumCrazyflies->setMaximum(6);
MainGUIWindow->setCentralWidget(centralWidget);
menuBar = new QMenuBar(MainGUIWindow);
menuBar->setObjectName(QStringLiteral("menuBar"));
......@@ -83,14 +84,15 @@ public:
retranslateUi(MainGUIWindow);
tabWidget->setCurrentIndex(-1);
QMetaObject::connectSlotsByName(MainGUIWindow);
} // setupUi
void retranslateUi(QMainWindow *MainGUIWindow)
{
MainGUIWindow->setWindowTitle(QApplication::translate("MainGUIWindow", "MainGUIWindow", 0));
tabWidget->setTabText(tabWidget->indexOf(tab), QApplication::translate("MainGUIWindow", "Tab 1", 0));
tabWidget->setTabText(tabWidget->indexOf(tab_2), QApplication::translate("MainGUIWindow", "Tab 2", 0));
} // retranslateUi
};
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.0.2, 2017-03-16T15:17:20. -->
<!-- Written by QtCreator 4.0.2, 2017-03-22T17:44:21. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment