Qt的笔记

  1. Qt的路径不支持中文
  2. 问题:'MyThread' does not name a type
    原因:thread.h包含usbtest.h,usbtest.h包含thread.h。头文件循环引用
  3. 问题:class UsbTest 里Mythread thread1; 中‘MyThread’ does not name a type
    原因:thread1.h包含usbtest.h, usbtest.h包含thread1.h
    防止重复引用的方法就是在每个头文件中加上ifndef/define/endif条件编译语句
    头文件重复引用是指一个头文件在同一个CPP文件中被INCLUDE了多次,这种错误常常是由于INCLUDE 嵌套造成的
  4. 全局变量
    (1)usbtest.h里声明extern struct libusb_device_handle 星devh;
    (2)usbtest.cpp里定义struct libusb_device_handle 星devh = NULL;
    (3)thread1.cpp里加#include "usbtest.h"

    自定义的结构体:
    struct test_state {
    libusb_device 星found;
    libusb_context 星ctx;
    libusb_device_handle 星handle;
    int attached;
    };
    extern struct test_state state;
  5. 局部变量
    (1)usbtest.h里定义结构体类型
    struct test_state {
    libusb_device 星found;
    libusb_context 星ctx;
    libusb_device_handle 星handle;
    int attached;
    };
    class UsbTest声明struct test_state state;
    (2)thread1.h里class Thread1声明struct test_state 星m_state;
    (3)usbtest.cpp里UsbTest的构造函数里加thread1.m_state = &state;

  6. 变量与系统重名,加static
  7. qt4 与 qt5的区别:pro文件里有widgets的是qt5

posted on 2017-08-16 23:13  shawn1416 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/shawnlxf/p/7345665.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值