Wiki

Clone wiki

QSugar / Home

QSugar contains some sugar for programs that use C++ & Qt.

It is based on QVariant and QDom* classes of Qt.

Documentation

Examples

Maps and lists

(QMAP
    << "one" >> 1
    << "three" >> "3"
    << "nested list" >> (QLIST
        << 4
        << QVariant(QLIST
            << "list"
            << "in a list"
        )
    )
    << "nested dictionary" >> (QMAP
        << "six" >> "6"
    )
)

More on QMAP and QLIST...

Initialization

Initialization of anonymous QObject (or its descendants) with QMAP-like syntax;

widget->layout()->addWidget(
    QNEW<QLabel>(widget)
    << "objectName" >> "a_label"
    << "text" >> "QSugar"
    << "toolTip" >> "QSugar test label"
    << "styleSheet" >> "font-weight: bold; color: magenta; background: black;"
    << "margin" >> 20
);

More on QNEW...

XML generation

QDomDocument sugarxml1 = QXML"html"
    > (QXML"head"
        <"title"> "Test page")
    > (QXML"body"
        <"h1"> "Hello world!"
        > (QXML"ul"
            <"li"> (QXML"a"
                <"@href"> "http://cblp.su/"
                > "cblp's page"
            )
            <"li"> (QXML"a"
                <"@href"> "http://qt.nokia.com/"
                > "Qt home"
            )
        )
    );

More on QXML...

Updated