Create a matrix from a .csv file
-
-
wrote on 31 May 2020, 01:57 last edited by
i have to do only this? morph into QWidget
-
Next step is to then include matrixwidget.h and
make it like it.
I dont know your structure so not sure why it dont see it.
You have to make it like the include. -
@AliM93
Yes to get rid of the promotion we tried. -
wrote on 31 May 2020, 01:58 last edited by
done, so now i have to include into file grid the matrix
-
@AliM93
yes and see if it will accept it.
Then we need to new a matrixwidget in GridDialog -
wrote on 31 May 2020, 02:00 last edited by
so i add the include of matrix.h in the grid.cpp
-
@AliM93
and it can compile? -
wrote on 31 May 2020, 02:00 last edited by
Build! thansk
-
wrote on 31 May 2020, 02:01 last edited by
i run it but obviouslt i can't see anything
-
wrote on 31 May 2020, 02:02 last edited by
because we have to add the matrix in the widget, right?
-
@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
-
wrote on 31 May 2020, 02:08 last edited by
done! but i only see the grid, not the content
-
@AliM93
\o/
Good work.
I hope you learn a few Creator tricks.we didnt paint the values yet :)
just all other stuff :=)But its 4 in the morning so rest must be tomorrow as its bed time for me :)
-
@AliM93
\o/
Good work.
I hope you learn a few Creator tricks.we didnt paint the values yet :)
just all other stuff :=)But its 4 in the morning so rest must be tomorrow as its bed time for me :)
-
wrote on 31 May 2020, 02:10 last edited by
anyway, ok for tomorrow, you have been too much patient with me, thanks. and for the first time, i can say thay i better undestand how qt works! i start to appreciate it
-
@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 } } }
-
wrote on 31 May 2020, 02:11 last edited by
yes i have
-
@AliM93
But it dont draw numbers ?
That seems very odd.But you do see grid ?
-
wrote on 31 May 2020, 02:13 last edited by
sorry! now i have, i lost a part of that version of matrix, sorry!
116/140