CANdevStudio
Development tool for CAN bus simulation
Loading...
Searching...
No Matches
subwindow.h
Go to the documentation of this file.
1#ifndef __SUBWINDOW_H
2#define __SUBWINDOW_H
3
4#include <QMdiSubWindow>
5#include <QPushButton>
6#include <QSize>
7#include <log.h>
8
9struct SubWindow : public QMdiSubWindow {
10 SubWindow(QWidget* parent)
11 : QMdiSubWindow(parent)
12 {
13 setAttribute(Qt::WA_DeleteOnClose);
14 setWindowIcon(QIcon(" "));
15 }
16
17 virtual void closeEvent(QCloseEvent* event) override
18 {
19 cds_debug("On closing");
20
21 // Allow to close the window but prevent deletion of the widget
22 setWidget(nullptr);
23 QMdiSubWindow::closeEvent(event);
24 }
25
26 virtual QSize minimumSizeHint() const override
27 {
28 return { 200, 100 };
29 }
30
31 virtual QSize sizeHint() const override
32 {
33 QSize size;
34
35 if (parentWidget()) {
36 size.setHeight(parentWidget()->size().height() / 2);
37 size.setWidth(parentWidget()->size().width() / 2);
38 } else {
39 cds_error("parentWidget() is NULL!");
40 }
41
42 return size;
43 }
44};
45
46#endif /* !__SUBWINDOW_H */
#define cds_debug(fmt,...)
Definition log.h:13
#define cds_error(fmt,...)
Definition log.h:21
Definition subwindow.h:9
virtual void closeEvent(QCloseEvent *event) override
Definition subwindow.h:17
SubWindow(QWidget *parent)
Definition subwindow.h:10
virtual QSize minimumSizeHint() const override
Definition subwindow.h:26
virtual QSize sizeHint() const override
Definition subwindow.h:31