#include "widget.h"
{
this->setGeometry(30,30,800,750);
rank
= new QLineEdit("Enter the Rank",
this);
//rank->setGeometry(10,0,20,20); ok
= new QPushButton("Ok",
this); ok
->setGeometry
(150,
0,
80,
30);
calculate
= new QPushButton("calculate",
this); calculate
->setGeometry
(250,
0,
80,
30);
connect(ok,SIGNAL(clicked()),this,SLOT(ok_clicked()));
connect(calculate,SIGNAL(clicked()),this,SLOT(calculate_clicked()));
}
Widget::~Widget()
{
}
void Widget::ok_clicked()
{
rank_of_Matrix = rank->text().toDouble();
tbl->setGeometry(20,50,770,250);
tbl->show();
Action_toArray(); // wrote all information into Array A[i][j] and make 0 all elements equals to zero
}
void Widget::calculate_clicked()
{
tbl ->setGeometry(20,350,770,250);
tbl->setItem(2,2, coppy->clone());
tbl ->show();
}
void Widget::Action_toArray()
{
A= new float* [rank_of_Matrix];
for(int i=0;i<rank_of_Matrix;i++){
A[i]=new float [rank_of_Matrix];
}
for(int i=0;i<rank_of_Matrix;i++){
for(int j=0;j<rank_of_Matrix;j++){
//wrote into Array from QTableWidget
A[i][j] = tbl->item(i,j)->data(Qt::DisplayRole).toFloat();
}
}
//make all elements equals to 2
for(int i=0;i<rank_of_Matrix;i++){
for(int j=0;j<rank_of_Matrix;j++){
if(A[i][j]==2){
A[i][j]=0;
}
}
}
}
#include "widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
this->setGeometry(30,30,800,750);
rank = new QLineEdit("Enter the Rank", this);//rank->setGeometry(10,0,20,20);
ok = new QPushButton("Ok", this); ok->setGeometry(150, 0,80,30);
calculate = new QPushButton("calculate",this); calculate->setGeometry(250,0,80,30);
coppy = new QTableWidgetItem;
connect(ok,SIGNAL(clicked()),this,SLOT(ok_clicked()));
connect(calculate,SIGNAL(clicked()),this,SLOT(calculate_clicked()));
}
Widget::~Widget()
{
}
void Widget::ok_clicked()
{
rank_of_Matrix = rank->text().toDouble();
tbl=new QTableWidget(rank_of_Matrix,rank_of_Matrix,this);
tbl->setGeometry(20,50,770,250);
tbl->show();
tbl->setItem(2,2,ptwi = new QTableWidgetItem(QString::number(40)));
Action_toArray(); // wrote all information into Array A[i][j] and make 0 all elements equals to zero
}
void Widget::calculate_clicked()
{
tbl = new QTableWidget(rank_of_Matrix,rank_of_Matrix,this);
tbl ->setGeometry(20,350,770,250);
tbl->setItem(2,2, coppy->clone());
tbl ->show();
}
void Widget::Action_toArray()
{
A= new float* [rank_of_Matrix];
for(int i=0;i<rank_of_Matrix;i++){
A[i]=new float [rank_of_Matrix];
}
for(int i=0;i<rank_of_Matrix;i++){
for(int j=0;j<rank_of_Matrix;j++){
//wrote into Array from QTableWidget
A[i][j] = tbl->item(i,j)->data(Qt::DisplayRole).toFloat();
}
}
//make all elements equals to 2
for(int i=0;i<rank_of_Matrix;i++){
for(int j=0;j<rank_of_Matrix;j++){
if(A[i][j]==2){
A[i][j]=0;
}
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks