Failed to link button code
Added by jupiter hce about 3 years ago
Hi,
Sorry I am learning Wt and Web development, I made following code in an application intending to display a button flashBootloaderButton to the web page:
std::unique_ptrWt::WWidget Manufacture::InstallBootloader(void) {
std::cout << "Calling Install bootloader" << std::endl;
auto result = std::make_unique();
WTemplate *requestTemplate = result->addWidget(std::make_unique(tr("home.installBootloader")));
requestTemplate->setTemplateText(tr("home.installBootloader"));
std::unique_ptrWt::WTemplate bootloaderWidget = std::make_uniqueWt::WTemplate(tr("home.installBootloader"));
std::unique_ptrWt::WPushButton flashBootloaderButton = std::make_uniqueWt::WPushButton(tr("flashBootloader"));
flashBootloaderButton->clicked().connect(this, &Manufacture::FlashBootloader);
}
The xml file has following code:
Install Bootloader Process
${flashBootloader}
When I run the application, the Manufacture::InstallBootloader is called, but the web page failed to display the button instead of error message "??flashBootloader??", what I am missing in the cpp code?
Thank you very much.
Kind regards.
Replies (2)
RE: Failed to link button code - Added by Korneel Dumon about 3 years ago
The ${flashBootloader}
represents a placeholder you can bind a widget to. So you would need to do: (not tested)
requestTemplate->bindWidget("flashBootloader", std::move(flashBootloaderButton));
RE: Failed to link button code - Added by jupiter hce about 3 years ago
Thanks Korneel, I added requestTemplate->bindWidget("flashBootloader", std::move(flashBootloaderButton));, it is still an error message"??flashBootloader??" failed to display the button.