2015.12.29
qt小白,今天遇到QTcpSocket头文件无法找到问题,解决办法是在工程的.pro文件里增加QT += network
原因是QT默认使用core和gui库,当需要使用除core和gui之外的库的时候就需要: QT +=webkit类似这样的来使QT获取webkit的库。
http://blog.youkuaiyun.com/tingsking18/article/details/4835088
2015.01.11
使用QVector<T> T是自定义继承自QObject的类,编译不通过,应该改为QVector<T*>
http://www.qtforum.org/article/22550/qvector.html?s=68acf37c7d090ffca5ffbea869168653ad5cc4ee#post80762
you can't create a vector of CVideoDeviceInput, it has no default constructor and no copy constructor: if you write QVector<CVideoDeviceInput>, QVector needs to know how to allocate CVideoDeviceInput, and it can't do it, because the only way to allocate CVideoDeviceInput is by calling CVideoDeviceInput( CVideoDeviceLinux *video, int channel ), and QVector can't know what "video" and "channel" shpuld be.
You need a QVector<CVideoDeviceInput*> instead, then you can call the constructor yourself, but beware of memory leaks!! (afaik there's also something like QPtrVector which does the same but takes care of memory)
QVector<T>排序,qsort()的使用
void qSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
对于自定义类型T,需定义lessThan函数。
需要注意的是lessThan函数不应该在头文件里也不应该是bool xxx::LessThan而是直接bool LessThan
http://stackoverflow.com/questions/5612906/why-wont-qsort-work