Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. QGridLayout mit Vector füllen
Forum Updated to NodeBB v4.3 + New Features

QGridLayout mit Vector füllen

Scheduled Pinned Locked Moved Unsolved German
2 Posts 2 Posters 305 Views 1 Watching
  • 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.
  • I Offline
    I Offline
    Isa456
    wrote on last edited by
    #1

    Hi,
    unzwar möchte ich gern ein Spielbett 10x10 entwickelt.
    Das soll in das QGridLayout rein, wie zeige ich mir das am besten an?

    void MainWindow::Board(){
    for (int i = 0; i < boardLength; i++)
    {
    for (int j = 0; j <boardLength; j++)

        { gameBoard[i][j]; //Gameboard ist ein QVector<String>
           ui->gridLayout->addWidget(gameBoard,i,j,1,1); //hier sagt er keine matching function
       
        }
    }
    

    }

    2c9ca462-8921-4d0c-9747-5c7fc3d2ee67-image.png image url)

    jsulmJ 1 Reply Last reply
    0
    • I Isa456

      Hi,
      unzwar möchte ich gern ein Spielbett 10x10 entwickelt.
      Das soll in das QGridLayout rein, wie zeige ich mir das am besten an?

      void MainWindow::Board(){
      for (int i = 0; i < boardLength; i++)
      {
      for (int j = 0; j <boardLength; j++)

          { gameBoard[i][j]; //Gameboard ist ein QVector<String>
             ui->gridLayout->addWidget(gameBoard,i,j,1,1); //hier sagt er keine matching function
         
          }
      }
      

      }

      2c9ca462-8921-4d0c-9747-5c7fc3d2ee67-image.png image url)

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Isa456 said in QGridLayout mit Vector füllen:

      gameBoard[i][j];

      Was soll diese Zeile denn bewirken?
      Wie wäre es mit:

      ui->gridLayout->addWidget(gameBoard[i][j],i,j,1,1);
      

      ?
      Falls gameBoard tatsächlich ein QVector<String> ist wird das nicht funktionieren, da es ja nicht 2 dimensional ist.
      "hier sagt er keine matching function" - hast du schon die Doku für addWidget gelesen? Das kann natürlich nicht funktionieren. addWidget erwartet (wie der Name bereits sagt) ein QWidget und nicht ein QVector oder QString.
      Denke noch mal darüber nach was du eigentlich machen willst.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

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