Advertisement
Guest User

delete.cpp

a guest
Oct 11th, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include "widget.h"
  2. #include <QFormLayout>
  3. #include <QHBoxLayout>
  4. #include <QVBoxLayout>
  5. #include <QDebug>
  6.  
  7. Widget::Widget(QWidget *parent)
  8.     : QWidget(parent)
  9. {
  10.     reset = new QPushButton("reset");
  11.  
  12.     box = new QGroupBox(0);
  13.  
  14.     mainLayout = new QVBoxLayout;
  15.     mainLayout->addWidget(reset);
  16.     mainLayout->addWidget(box);
  17.  
  18.     setLayout(mainLayout);
  19.  
  20.     connect(reset, SIGNAL(clicked()), this, SLOT(resetPressed()));
  21.  
  22.     show();
  23.  
  24.     qDebug() <<"init end";
  25. }
  26.  
  27. void Widget::resetPressed()
  28. {
  29.     box->hide();
  30.     box->deleteLater();
  31.  
  32.     box = new QGroupBox(this);
  33.     boxLayout = new QFormLayout();
  34.  
  35.     for(unsigned int i=0; i<3; i++)
  36.     {
  37.         QPushButton *trickyButton = new QPushButton;
  38.         boxLayout->addRow("hopeless button", trickyButton);
  39.     }
  40.  
  41.     mainLayout->addWidget(box);
  42.     box->setLayout(boxLayout);
  43.     box->show();
  44.  
  45.     qDebug() << "items after add: " << boxLayout->count();
  46. }
  47.  
  48. Widget::~Widget()
  49. {
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement