Project

General

Profile

Bug #6379 ยป issue_6379.cpp

Roel Standaert, 05/24/2018 04:05 PM

 
#include <Wt/WApplication.h>
#include <Wt/WContainerWidget.h>
#include <Wt/WDialog.h>
#include <Wt/WPushButton.h>
#include <Wt/WServer.h>

int main(int argc, char *argv[])
{
return Wt::WRun(argc, argv, [](const Wt::WEnvironment &env){
auto app = std::make_unique<Wt::WApplication>(env);
auto root = app->root();

auto dialog1 = app->addChild(std::make_unique<Wt::WDialog>(Wt::utf8("Dialog 1")));
dialog1->setModal(false);
dialog1->setClosable(true);

Wt::WPushButton *btn =
dialog1->contents()->addNew<Wt::WPushButton>(Wt::utf8("Open dialog 2"));
btn->clicked().connect([app=app.get()]{
auto dialog2 = app->addChild(std::make_unique<Wt::WDialog>(Wt::utf8("Dialog 2")));
dialog2->setModal(false);
Wt::WPushButton *btn =
dialog2->contents()->addNew<Wt::WPushButton>(Wt::utf8("Close dialog 2"));
btn->clicked().connect([dialog2, app]{
app->removeChild(dialog2);
});
dialog2->show();
});

dialog1->show();

return app;
});
}
    (1-1/1)