Friday, 15 March 2013

c++11 - C++, namespaces, name lookup on inherited class and Qt -



c++11 - C++, namespaces, name lookup on inherited class and Qt -

i have built qt5 qt_namespace=qt_ns option.

the next code compiles ok. why?

qt_begin_namespace namespace ui { class mainwindow; } qt_end_namespace namespace test_ns { class mainwindow : public qmainwindow { q_object public: explicit mainwindow(qwidget *parent = 0); ~mainwindow(); private: qt_ns::ui::mainwindow *ui; }; }

qmainwindow wrapped in namespace qt_ns have thought necessary prefix name qt_ns in

class mainwindow : public qt_ns::qmainwindow

i have googled in vain, reading c++ standard no avail. not think adl applicable here applies function, err, arguments. have searched qt sources on qmainwindow got lost in too.

so, on , extend knowledge please.

check qglobal.h you'll see qt_use_namespace when qt_no_using_namespace not defined. next comment:

# ifndef qt_no_using_namespace /* expands "using qt_namespace" in _header files_. way feature can used without much pain, if people _really_ not want can add together defines += qt_no_using_namespace .pro files. */ qt_use_namespace # endif

this allows using qmainwindow straight without using namespaces

c++ c++11 qt

No comments:

Post a Comment