#include "MaFenetre.h" MaFenetre::MaFenetre() : QWidget() { m_nbdisques=0; setFixedSize(1000, 600); m_boutonDialogue = new QPushButton("DEBUT", this); m_AB = new QPushButton("vers B", this); m_AC = new QPushButton("vers C", this); m_BA = new QPushButton("vers A", this); m_BC = new QPushButton("vers C", this); m_CA = new QPushButton("vers A", this); m_CB = new QPushButton("vers B", this); m_solution= new QPushButton("solution",this); m_solution->move(150,50); m_AB->move(165,500); m_AC->move(165,530); m_BA->move(465,500); m_BC->move(465,530); m_CA->move(765,500); m_CB->move(765,530); m_boutonDialogue->move(40, 50); for(int i=0;i<10;i++) {m_axA[i]=i; m_axB[i]=10; m_axC[i]=10; } QObject::connect(m_boutonDialogue, SIGNAL(clicked()), this, SLOT(ouvrirDialogue())); QObject::connect(m_AB, SIGNAL(clicked()), this, SLOT(deplacerAB())); QObject::connect(m_AC, SIGNAL(clicked()), this, SLOT(deplacerAC())); QObject::connect(m_BA, SIGNAL(clicked()), this, SLOT(deplacerBA())); QObject::connect(m_BC, SIGNAL(clicked()), this, SLOT(deplacerBC())); QObject::connect(m_CA, SIGNAL(clicked()), this, SLOT(deplacerCA())); QObject::connect(m_CB, SIGNAL(clicked()), this, SLOT(deplacerCB())); QObject::connect(m_solution, SIGNAL(clicked()), this, SLOT(deplacer111())); comp=0; cmp=0; axe1=0; axe2=0; axe3=0; tableau = new int[2046]; for(int j=0;j<2046;j++) tableau[j]=0; QLabel *label = new QLabel("Salut", this); label->move(30, 20); } void MaFenetre::ouvrirDialogue() { m_nbdisques = QInputDialog::getInteger(this, "Nombres de disques", "Entrez le nombre de disques",5,1,10); m_A = m_nbdisques; m_B=0; m_C=0; } void MaFenetre::afficherDisques() { for(int j=0;j<10;j++) disque[j] =QRectF(50+10*j,480-20*j,300-20*j,20); update(); } void MaFenetre::deplacerAB() { if(m_A!=0) { if(m_B==0) { m_axB[0]=m_axA[m_A-1]; QPointF po(500,490); disque[m_axA[m_A-1]].moveCenter(po); m_A--; m_B++; } else if(m_axB[m_B-1]stop(); timer->start(1000); cmp=cmp+2; } void MaFenetre::sol() {if(cmp axes; axes << ax1 << ax2 << ax3 ; QPainter myPainter(this); myPainter.setBrush(Qt::gray); myPainter.drawRects(axes); }