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 48 49 50
|
#include "test.h"
#include <iostream>
#define N 3 //nombre de reine que je recupere via un formulaire
Test::Test() : QMainWindow()
{
//Zone de trouble
this->setFixedSize(800, 600); // Marche pas..
scene = new QGraphicsScene(); //Une fois la logique comprise je mettrai certains objets dans la class Test
vue = new QGraphicsView(scene);
vue->showMaximized();
QBrush bbrush(Qt::black);
QBrush wbrush(Qt::white);
QPen pen;
//Algorithme d'echiquier
int i;
int j = 0;
while (j < N)
{
i = 0;
while (i < N)
{
if (i % 2 == 0)
{
if (j % 2 == 0)
scene->addRect(i * 100, j * 100, 100, 100, pen, bbrush);
else
scene->addRect(i * 100, j * 100, 100, 100, pen, wbrush);
}
else
{
if (j % 2 == 1)
scene->addRect(i * 100, j * 100, 100, 100, pen, bbrush);
else
scene->addRect(i * 100, j * 100, 100, 100, pen, wbrush);
}
i++;
}
j++;
}
vue->show();
}
Test::~Test()
{
} |
Partager