linux之qt 第一个qt程序

在传统的教学和视频中都使用qtcreate 来进行创建工程,使用qmake来编译

其实都差不多,现在我使用meson来编写

编写qt程序

#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QLabel label("Hello, world");
    label.show();

    return app.exec();
}

编写meson.build

project('project01', ['c', 'cpp'])

qt5 = import('qt5')

qt5_modules = ['Core', 'DBus', 'Widgets']

qt5dep = dependency('qt5', modules : qt5_modules)

generated_files = qt5.preprocess(
    dependencies: qt5dep)

executable(
        'hello',   #生成运行程序名'hello.cpp',
        generated_files,
        dependencies : qt5dep,
       )

编译 

meson build
ninja -C build/

 

posted @ 2022-06-09 22:55  梦里花开一季  阅读(90)  评论(0编辑  收藏  举报