File indexing completed on 2022-11-23 10:29:24

0001 #include "khboxtest.h"
0002 #include <QPushButton>
0003 #include <QApplication>
0004 
0005 KHBoxTest::KHBoxTest(QWidget *parentWidget)
0006     : KHBox(parentWidget)
0007 {
0008     pbAdd = new QPushButton(QLatin1String("Add a button"), this);
0009     connect(pbAdd, SIGNAL(clicked()), this, SLOT(slotAdd()));
0010     pbRemove = nullptr;
0011 }
0012 
0013 void KHBoxTest::slotAdd()
0014 {
0015     if (!pbRemove) {
0016         pbRemove = new QPushButton(QLatin1String("Remove me"), this);
0017         connect(pbRemove, SIGNAL(clicked()), this, SLOT(slotRemove()));
0018         pbAdd->setEnabled(false);
0019     }
0020 }
0021 
0022 void KHBoxTest::slotRemove()
0023 {
0024     pbAdd->setEnabled(true);
0025     pbRemove->deleteLater();
0026     pbRemove = nullptr;
0027 }
0028 
0029 int main(int argc, char **argv)
0030 {
0031     QApplication app(argc, argv);
0032 
0033     KHBoxTest *toplevel = new KHBoxTest(nullptr);
0034     toplevel->show();
0035     app.exec();
0036 }
0037