Create a matrix from a .csv file
Solved
General and Desktop
-
Hmm
it seems cmake is confused.
about the includes.Lets demote the widget and then you can add it to the dialog as you normal does.
Demote is important else you get error for ever.
sec.
shots -
ok go to
GridDialog UI
and then right click the widget
THIS IS ULTRA IMPORTANT as ELSE it will fail again and again as it still remembers the promotion.
-
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.
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 } } }