• QT1 HelloWorld


    项目需要,故学习QT

    之前对此毫无了解,就当入学上课,看下自己的自学如何

    1. 安装

    选择傻瓜安装

    下载

    http://mirrors.neusoft.edu.cn/qt/official_releases/online_installers/qt-opensource-linux-x64-1.6.0-2-online.run

    根据自己的系统找对应安装


    2. chmod +x qt-opensource-linux-x64-1.6.0-2-online.run

    ./qt-opensource-linux-x64-1.6.0-2-online.run

    找到对应的安装文件,联网安装就是了,前面可能需要 sudo


    3. 安装完成后,环境算是配置好了

    期间需要你选择安装的路径,我的/opt/QT这个好像是默认的


    4. 编写helloworld文件

    #include <QtWidgets/QApplication>
    #include <QtWidgets/QLabel>
    int main(int argc, char *argv[]) {
      QApplication app(argc, argv);
      QLabel hello("<center>Welcome to my first WikiHow Qt program</center>");
      hello.setWindowTitle("My First WikiHow Qt Program");
      hello.resize(400, 400);
      hello.show();
      return app.exec();
    }

    执行

    qmake -project

    qmake

    make

    得到程序


    5. 期间会有如下问题:

    qmake找不到

    到/usr/bin中看到确实有个qmake文件,但是为什么还是找不到了?

    ll /usr/bin/qmake

    发现qmake是一个链接,指向的不是qmake

    那就改呗

    sudo ln -s /opt/Qt/5.3/gcc_64/bin/qmake  /usr/bin/qmake

    还有/usr/bin中好多和qt相关的链接都没有,这个估计没安装qt时老版权的连接,而且都有改动了

    6. 

    期间得到-lGL的链接错误,安装mesa

    apt-get install libgl1-mesa-dev

    7.

    链接错误

    在helloworld.pro文件中添加一行

    QT += widget

    这样就能得到程序了,运行后就可以了


    8. 

    还有一个方法,也是最简单的,直接用IDE


    1. Q+= w

    每天早上叫醒你的不是闹钟,而是心中的梦~
  • 相关阅读:
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
  • 原文地址:https://www.cnblogs.com/vintion/p/4116889.html
Copyright © 2020-2023  润新知