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. Update QGridLayout ?
Forum Updated to NodeBB v4.3 + New Features

Update QGridLayout ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 288 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.
  • Ramkumar MohanR Offline
    Ramkumar MohanR Offline
    Ramkumar Mohan
    wrote on last edited by Chris Kawa
    #1

    I placed the pushbuttons in gridlayout after creating them in Qt. then stored the buttons data's in a sqlite database.

    QSqlQuery query;
        query.prepare("SELECT name FROM table");
        query.exec();
        int count=0;
        while(query.next())
        {
            QString s=query.value(0).toString();
            array[count]=s;
            count++;
            //qDebug()<<s;
        }
        int count1=0;
        const QSize btnSize = QSize(150, 50);
        for (int i=0;i<15 ;i++ )
        {
            for (int j=0;j<5 ;j++ )
            {
                if(count1==count)
                    break;
                else
                {
                    QPushButton *button = new QPushButton(array[count1]);
                    button->setFixedSize(btnSize);
                    button->setObjectName(array[count1]);
                    connect(button, &QPushButton::clicked, this,&MainWindow::cald);
                    ui->gridLayout->addWidget(button,i,j);
                    count1++;
                }
            }
        }
    

    I'm removing a pushbutton from another gridlayout. How do you update a different grid layout?
    I tried but , I don't know how, if you know please tell me .

    Thank you

    JonBJ 1 Reply Last reply
    0
    • Ramkumar MohanR Ramkumar Mohan

      I placed the pushbuttons in gridlayout after creating them in Qt. then stored the buttons data's in a sqlite database.

      QSqlQuery query;
          query.prepare("SELECT name FROM table");
          query.exec();
          int count=0;
          while(query.next())
          {
              QString s=query.value(0).toString();
              array[count]=s;
              count++;
              //qDebug()<<s;
          }
          int count1=0;
          const QSize btnSize = QSize(150, 50);
          for (int i=0;i<15 ;i++ )
          {
              for (int j=0;j<5 ;j++ )
              {
                  if(count1==count)
                      break;
                  else
                  {
                      QPushButton *button = new QPushButton(array[count1]);
                      button->setFixedSize(btnSize);
                      button->setObjectName(array[count1]);
                      connect(button, &QPushButton::clicked, this,&MainWindow::cald);
                      ui->gridLayout->addWidget(button,i,j);
                      count1++;
                  }
              }
          }
      

      I'm removing a pushbutton from another gridlayout. How do you update a different grid layout?
      I tried but , I don't know how, if you know please tell me .

      Thank you

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Ramkumar-Mohan said in Update QGridLayout ?:

      I'm removing a pushbutton from another gridlayout.

      No you're not, you're adding a newed button.

      How do you update a different grid layout?

      What do you mean? Here you are changing ui->gridLayout, obviously if you have another grid layout, ui->gridlayout2, then use that instead.

      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