//main.cpp
#include <QtGui>
#include "MyWizard.h"
{
Q_OBJECT
public:
{
layout->addWidget(add, layout->rowCount(), 0);
connect(add, SIGNAL(clicked()), this, SLOT(addWidgets()));
}
private slots:
void addWidgets()
{
layout->addWidget(clear, layout->rowCount(), 0);
layout->addWidget(label, layout->rowCount() - 1, 1);
layout->addWidget(lineEdit,layout->rowCount() - 1, 2);
layout->addWidget(label2, layout->rowCount() - 1, 3);
layout->addWidget(comboBox,layout->rowCount() - 1, 4);
connect(clear, SIGNAL(clicked()), label, SLOT(deleteLater()));
connect(clear, SIGNAL(clicked()), lineEdit, SLOT(deleteLater()));
connect(clear, SIGNAL(clicked()), label2, SLOT(deleteLater()));
connect(clear, SIGNAL(clicked()), comboBox, SLOT(deleteLater()));
connect(clear, SIGNAL(clicked()), clear, SLOT(deleteLater()));
}
private:
};
int main(int argc, char *argv[])
{
MyWidget w;
w.show();
return a.exec();
}
#include "main.moc"
//main.cpp
#include <QtGui>
#include "MyWizard.h"
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget(QWidget* parent = 0)
: QWidget(parent)
, layout(new QGridLayout(this))
, add(new QPushButton("Add Widgets", this))
{
layout->addWidget(add, layout->rowCount(), 0);
connect(add, SIGNAL(clicked()), this, SLOT(addWidgets()));
}
private slots:
void addWidgets()
{
QPushButton* clear = new QPushButton("Clear Widgets", this);
QLineEdit* lineEdit = new QLineEdit;
QLabel* label = new QLabel("ENTER SEARCH KEY");
QLabel* label2 = new QLabel("UNDER THE TAG");
QComboBox* comboBox = new QComboBox;
layout->addWidget(clear, layout->rowCount(), 0);
layout->addWidget(label, layout->rowCount() - 1, 1);
layout->addWidget(lineEdit,layout->rowCount() - 1, 2);
layout->addWidget(label2, layout->rowCount() - 1, 3);
layout->addWidget(comboBox,layout->rowCount() - 1, 4);
connect(clear, SIGNAL(clicked()), label, SLOT(deleteLater()));
connect(clear, SIGNAL(clicked()), lineEdit, SLOT(deleteLater()));
connect(clear, SIGNAL(clicked()), label2, SLOT(deleteLater()));
connect(clear, SIGNAL(clicked()), comboBox, SLOT(deleteLater()));
connect(clear, SIGNAL(clicked()), clear, SLOT(deleteLater()));
}
private:
QGridLayout* layout;
QPushButton* add;
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyWidget w;
w.show();
return a.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks