How usable is Qt without its preprocessing step?

后端 未结 12 791
自闭症患者
自闭症患者 2021-02-02 05:21

I think it\'s unreasonable for a library to require preprocessing of my source code with a special tool. That said, several people have recommended the Qt library to me for cros

12条回答
  •  余生分开走
    2021-02-02 05:45

    Using Qt while avoiding moc will be more difficult than just using them together as intended. You will also sacrifice most of the interesting features that motivated others to recommend Qt.

    Without moc you can't

    • Use signals & slots (which are all but required for UI)
    • Use the dynamic property system (needed to write plugins, among other things)
    • Use the internationalization features
    • Expect to get help from anybody when nothing works

    If you want to use Qt, use moc. In fact, don't even worry about moc -- just use QMake. You can write a QMake .pro file that looks like this:

    TARGET = myApp
    
    FORMS += MainWindow.ui
    
    HEADERS += MainWindow.h
    
    SOURCES += MainWindow.cpp
    SOURCES += main.cpp
    

    Everything will be taken care of automatically. Or you can spend all your time trying to figure out how to avoid moc.

    See https://doc.qt.io/archives/qt-4.7/metaobjects.html and https://doc.qt.io/archives/qt-4.7/moc.html#moc

提交回复
热议问题