Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Create a matrix from a .csv file

Create a matrix from a .csv file

Scheduled Pinned Locked Moved Solved General and Desktop
140 Posts 2 Posters 51.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AliM93
    wrote on 31 May 2020, 01:52 last edited by
    #104
    This post is deleted!
    1 Reply Last reply
    0
    • A AliM93
      31 May 2020, 01:50

      i get this error when i clean.. but i don't know why

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 31 May 2020, 01:52 last edited by
      #105

      @AliM93
      its due to you having the auto generated file open
      just press Close.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 31 May 2020, 01:54 last edited by
        #106

        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

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 31 May 2020, 01:56 last edited by
          #107

          ok go to
          GridDialog UI
          and then right click the widget
          alt text

          THIS IS ULTRA IMPORTANT as ELSE it will fail again and again as it still remembers the promotion.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            AliM93
            wrote on 31 May 2020, 01:57 last edited by
            #108

            i have to do only this? morph into QWidget

            M 1 Reply Last reply 31 May 2020, 01:57
            0
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 31 May 2020, 01:57 last edited by
              #109

              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.

              1 Reply Last reply
              0
              • A AliM93
                31 May 2020, 01:57

                i have to do only this? morph into QWidget

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 31 May 2020, 01:57 last edited by
                #110

                @AliM93
                Yes to get rid of the promotion we tried.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  AliM93
                  wrote on 31 May 2020, 01:58 last edited by
                  #111

                  done, so now i have to include into file grid the matrix

                  M 1 Reply Last reply 31 May 2020, 01:59
                  0
                  • A AliM93
                    31 May 2020, 01:58

                    done, so now i have to include into file grid the matrix

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 31 May 2020, 01:59 last edited by
                    #112

                    @AliM93
                    yes and see if it will accept it.
                    Then we need to new a matrixwidget in GridDialog

                    A 1 Reply Last reply 31 May 2020, 02:00
                    0
                    • M mrjj
                      31 May 2020, 01:59

                      @AliM93
                      yes and see if it will accept it.
                      Then we need to new a matrixwidget in GridDialog

                      A Offline
                      A Offline
                      AliM93
                      wrote on 31 May 2020, 02:00 last edited by
                      #113

                      so i add the include of matrix.h in the grid.cpp

                      M 1 Reply Last reply 31 May 2020, 02:00
                      0
                      • A AliM93
                        31 May 2020, 02:00

                        so i add the include of matrix.h in the grid.cpp

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 31 May 2020, 02:00 last edited by
                        #114

                        @AliM93
                        and it can compile?

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          AliM93
                          wrote on 31 May 2020, 02:00 last edited by
                          #115

                          Build! thansk

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            AliM93
                            wrote on 31 May 2020, 02:01 last edited by
                            #116

                            i run it but obviouslt i can't see anything

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              AliM93
                              wrote on 31 May 2020, 02:02 last edited by
                              #117

                              because we have to add the matrix in the widget, right?

                              M 1 Reply Last reply 31 May 2020, 02:05
                              0
                              • A AliM93
                                31 May 2020, 02:02

                                because we have to add the matrix in the widget, right?

                                M Offline
                                M Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on 31 May 2020, 02:05 last edited by mrjj
                                #118

                                @AliM93
                                yes.
                                You should still have the layout from before, correct ?
                                then in Grids constrcutor

                                GridDialog::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

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  AliM93
                                  wrote on 31 May 2020, 02:08 last edited by
                                  #119

                                  done! but i only see the grid, not the content

                                  M 1 Reply Last reply 31 May 2020, 02:09
                                  0
                                  • A AliM93
                                    31 May 2020, 02:08

                                    done! but i only see the grid, not the content

                                    M Offline
                                    M Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on 31 May 2020, 02:09 last edited by
                                    #120

                                    @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 :)

                                    A 1 Reply Last reply 31 May 2020, 02:10
                                    0
                                    • M mrjj
                                      31 May 2020, 02:09

                                      @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 :)

                                      A Offline
                                      A Offline
                                      AliM93
                                      wrote on 31 May 2020, 02:10 last edited by
                                      #121

                                      @mrjj yes! but i don't even see the number

                                      M 1 Reply Last reply 31 May 2020, 02:11
                                      0
                                      • A Offline
                                        A Offline
                                        AliM93
                                        wrote on 31 May 2020, 02:10 last edited by
                                        #122

                                        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

                                        1 Reply Last reply
                                        0
                                        • A AliM93
                                          31 May 2020, 02:10

                                          @mrjj yes! but i don't even see the number

                                          M Offline
                                          M Offline
                                          mrjj
                                          Lifetime Qt Champion
                                          wrote on 31 May 2020, 02:11 last edited by
                                          #123

                                          @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
                                                  }
                                              }
                                          
                                          }
                                          
                                          1 Reply Last reply
                                          0

                                          113/140

                                          31 May 2020, 02:00

                                          • Login

                                          • Login or register to search.
                                          113 out of 140
                                          • First post
                                            113/140
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved