WT:WContainerWidget对象导致编译错误

时间:2018-11-06 18:20:48

标签: c++ visual-c++ wt

目前,我正在尝试熟悉Emweb的Webtoolkit(Wt或“ Witty”)。作为我的第一个项目,我决定写一个夸张的Company-Homepage。但是当我尝试实现某种Content-Management-System时,Visual Studio的行为变得完全奇怪。由于自然而然地产生了一堆错误,所以我将代码的所有行都注释掉到最低限度,以便编译并找出我的错误。我是盲目的还是不在那里?是我的3个对象的代码,导致错误的行被注释:

main.cpp:

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

        //>>loading layout.xml for page-layout
        app->messageResourceBundle().use("approot/layout");

        app->messageResourceBundle().use("approot/strings_de");
        //>>loading strings_de.xml for messages
        app->useStyleSheet("docroot/style.css");
        //>>loading style.css for used stylesheet
        app->root()->addNew<TLayout>();

        return app;
    });

}

CHeadline.h:

class CHeadline : public WContainerWidget
{
public:
    CHeadline();

private:
    WImage* Game_Logo;
    WImage* Corner_Image;
};

CHeadline.cpp:

#include "CHeadline.h"

CHeadline::CHeadline()
{
    this->setStyleClass("headline");
    Game_Logo = addWidget(make_unique<WImage>("image/game_logo.png"));
    Game_Logo->setStyleClass("logo");

    Corner_Image = addWidget(make_unique<WImage>("image/right_corner.png"));
    Corner_Image->setStyleClass("img_hl");
}

CNavbar.h:

class CNavbar : public Wt::WContainerWidget
{
public:
    CNavbar();
    ~CNavbar();

private:
    WPushButton* b_news;
    WPushButton* b_webdev;
    WPushButton* b_projects;
    WPushButton* b_media;
    WPushButton* b_shop;
    WPushButton* b_about;
};

CNavbar.cpp:

CNavbar::CNavbar()
{
    this->setStyleClass("navbar");

    //INIT_BUTTONS:*****///

    b_news = addWidget(make_unique<WPushButton>(tr("str.news")));

    b_webdev = addWidget(make_unique<WPushButton>(tr("str.webdev")));

    b_projects = addWidget(make_unique<WPushButton>(tr("str.projects")));

    b_media = addWidget(make_unique<WPushButton>(tr("str.media")));

    b_shop = addWidget(make_unique<WPushButton>(tr("str.shop")));

    b_about = addWidget(make_unique<WPushButton>(tr("str.about")));
}

这里是结合了所有内容的布局模板:

TLayout.h:

class TLayout : public WTemplate
{
public:
    TLayout();
    ~TLayout();
    enum SECTION { NEWS, DEV, PROJ, MEDIA, SHOP, CONTACT };
    void setSection(SECTION aSec);

private:
    //Adding Widget for the Headline (Logo + Corner Image)
    CHeadline* wHeadline;
    CNavbar* wNavbar; //PROBLEM-LINE
    SECTION currentSec;
};

TLayout.cpp:

TLayout::TLayout() : WTemplate { tr("tpl.layout") }
{
    currentSec = NEWS; //Standard-Wert für Section
    this->setStyleClass("bglayout");

    wHeadline = bindWidget("HEADLINE", make_unique<CHeadline>());
    wNavbar = bindWidget("NAVIGATION", make_unique<CNavbar>()); //PROBLEM?
}

void TLayout::setSection(SECTION aSec) {
}

考虑到所有的Includes和Namespaces都是正确的,为什么不编译? Visual Studio给我以下错误:

tlayout.h (38): Unexpected Token before ";"
tlayout.h (38): Syntaxerror. ";" missing before "*"
tlayout.h (38): Missing Type-Specification

0 个答案:

没有答案