Newer
Older
Grégoire Payen de La Garanderie
committed
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
#include "simul/main_window.h"
#include "simul/table.h"
#include <QTimer>
#include <iostream>
#include <QVBoxLayout>
#include <QResizeEvent>
MainWindow::MainWindow()
{
QTimer* timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
dt = 10;
timer->start(dt);
QWidget* inter = new QWidget(this);
setCentralWidget(inter);
inter->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
table = new Table(inter);
}
MainWindow::~MainWindow()
{
}
void MainWindow::update()
{
table->update(dt);
}
void MainWindow::resizeEvent(QResizeEvent* event)
{
float proportion = (float)table->tableWidth/table->tableHeight;
QSize s = event->size();
if(s.width() < s.height()*proportion)
table->resize(s.width(),s.width()/proportion);
else
table->resize(proportion*s.height(),s.height());
}
#include "main_window.moc"