Hello,
As the title is saying , I am trying to put the result of a user input , in a QTableWidget, and take this QTableWidget to fillin an array.
I have read the documentation but infortunetly I can not do it .
Here is the code:
//the header
#ifndef FENPRINCIPALE_H
#define FENPRINCIPALE_H
#include <QtGui>
#include <vector>
class FenPrincipale
: public QWidget{
Q_OBJECT
public:
FenPrincipale();
bool M[2][2];
private slots:
private:
};
#endif
//FenPrincipale.cpp
#include "qDebug.h"
#include "FenPrincipale.h"
FenPrincipale::FenPrincipale()
{
int o,p;
for (o=0; o<2; o++)
{
for (p=0; p<2; p++)
{
(M[o][p])=false;
}
}
for (o=0; o<2; o++)
{
for (p=0; p<2; p++)
{
element=(tableWidget->itemAt((o+1),(p+1)));
if ((element->toString)="1")
{
M[o][p]=true;
}
else
{
M[o][p]=false;
}
}
}
}
//main.cpp
#include <QApplication>
#include "FenPrincipale.h"
int main(int argc, char* argv[])
{
FenPrincipale fenetre;
fenetre.show();
return app.exec();
}
//the header
#ifndef FENPRINCIPALE_H
#define FENPRINCIPALE_H
#include <QtGui>
#include <vector>
class FenPrincipale : public QWidget
{
Q_OBJECT
public:
FenPrincipale();
bool M[2][2];
QTableWidgetItem * element;
private slots:
private:
QTableWidget* tableWidget;
};
#endif
//FenPrincipale.cpp
#include "qDebug.h"
#include "FenPrincipale.h"
FenPrincipale::FenPrincipale()
{
int o,p;
tableWidget = new QTableWidget(2,2,this);
element = new QTableWidgetItem (1000);
for (o=0; o<2; o++)
{
for (p=0; p<2; p++)
{
(M[o][p])=false;
}
}
for (o=0; o<2; o++)
{
for (p=0; p<2; p++)
{
element=(tableWidget->itemAt((o+1),(p+1)));
if ((element->toString)="1")
{
M[o][p]=true;
}
else
{
M[o][p]=false;
}
}
}
}
//main.cpp
#include <QApplication>
#include "FenPrincipale.h"
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
FenPrincipale fenetre;
fenetre.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Thank you very much for the attention given to this message.
Bookmarks