⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Wt
All Projects
Wt
Overview
Activity
Roadmap
Issues
Wiki
Forums
Download (1.43 KB)
Bug #7009
ยป main.cpp
Maximilian Kleinert
, 04/18/2019 10:19 AM
#include
<Wt/WApplication.h>
#include
<Wt/WContainerWidget.h>
#include
<Wt/WPushButton.h>
#include
<Wt/WPopupMenu.h>
#include
<Wt/WNavigationBar.h>
class
MyApp
:
public
Wt
::
WApplication
{
public:
explicit
MyApp
(
const
Wt
::
WEnvironment
&
env
)
:
Wt
::
WApplication
(
env
)
{
menu_
=
root
()
->
addNew
<
Wt
::
WNavigationBar
>
()
->
addMenu
(
Wt
::
cpp14
::
make_unique
<
Wt
::
WMenu
>
());
auto
item
=
std
::
make_unique
<
Wt
::
WMenuItem
>
(
"Popup Menu"
);
auto
popupMenu
=
Wt
::
cpp14
::
make_unique
<
Wt
::
WPopupMenu
>
();
popupMenu
->
addItem
(
"Delete Popup Menu"
)
->
triggered
().
connect
([
=
]
{
for
(
auto
item
:
menu_
->
items
())
menu_
->
removeItem
(
item
);
});
item
->
setMenu
(
std
::
move
(
popupMenu
));
menu_
->
addItem
(
std
::
move
(
item
));
auto
popupButton
=
Wt
::
cpp14
::
make_unique
<
Wt
::
WPopupMenu
>
();
popupButton
->
addItem
(
"Delete Popup Button"
)
->
triggered
().
connect
([
=
]
{
root
()
->
removeWidget
(
button_
);
});
button_
=
root
()
->
addWidget
(
Wt
::
cpp14
::
make_unique
<
Wt
::
WPushButton
>
(
"Popup Button"
));
button_
->
setMenu
(
std
::
move
(
popupButton
));
}
private
:
Wt
::
WPushButton
*
button_
;
Wt
::
WMenu
*
menu_
;
};
std
::
unique_ptr
<
Wt
::
WApplication
>
createApplication
(
const
Wt
::
WEnvironment
&
env
)
{
std
::
unique_ptr
<
Wt
::
WApplication
>
app
=
std
::
make_unique
<
MyApp
>
(
env
);
return
app
;
}
int
main
(
int
argc
,
char
**
argv
)
{
return
Wt
::
WRun
(
argc
,
argv
,
&
createApplication
);
}
(1-1/1)
Loading...