Create a matrix from a .csv file
Solved
General and Desktop
-
@AliM93
yes.
You should still have the layout from before, correct ?
then in Grids constrcutorGridDialog::GridDialog(QWidget *parent) : QDialog(parent), ui(new Ui::GridDialog) { ui->setupUi(this); MatrixWidget * m = new MatrixWidget (this); ui->verticalLayout->addWidget(m); /// you name might differ for layout }
We dont need the plain widget any more. you can delete it. we use the layout
-
@AliM93
well do you have that version of paint ?void MatrixWidget::paintEvent(QPaintEvent *event) { QPainter p(this); // draw frame. p.drawRect(0, 0, width() - 1, height() - 1); // size of area we have. w = width , h = height , we take 2 pixles for border int w = width() - 2; int h = height() - 2; // now we find out how big each box should be which area we have divided with how many on x and y bw = w / max_x; bh = h / max_y; // now we loop and drw the boxes for (int xi = 0; xi < max_x; ++xi) { for (int yi = 0; yi < max_x; ++yi) { p.drawRect( QRect( xi * bw, yi * bh, bw, bh ) ) ; p.drawText(QRect( xi * bw, yi * bh, bw, bh ), QString::number(xi + 1) + "," + QString::number(yi+1) ); // the +1 aswe dont want to use first at 0,0 } } }
-
@AliM93
Ok that good news as it would be very impossible that numbers went missing :)what is remaining is the click logic and to actual draw the 1.
how shall we draw 0 ones ?
just no value in cell and cant be selected or what is the goal?