1. 在结构体中含有一些qt的类型变量(对象类),并不能通过memset()初始化,这会导致使用或删除时崩溃,举例简单说memset会将qstring置为空指针,这时候你去赋值,直接接会崩溃。

2.比如在一个widget中你new了一个button,此时你在resize事件中move它到指定位置,并且你connect他的信号,并检查了一切,发现没有问题,但是问题是点击按钮时始终无法触发clicked事件,这是因为button被放在了下层,点击事件并没有传递到button上,所以此时的一种解决办法是:button->raise();

3.qt中qfile or qfileinfo打开含有中文路径的文件时会失败,这时候尝试网上编码转换等操作均失败时,此时将源文件设置为 utf-8 with bom保存,并且代码中设置#pragma execution_character_set("utf-8"),此时打开正常,顺便一说使用fopen等系统函数打开(QString)中文路径时可以如下操作:      

const wchar_t * encodedName = reinterpret_cast<const wchar_t *>(m_sSaveFileName.utf16());
m_pSaveFileHandle = _wfopen(encodedName, L"wb");

4. qSort使用,compare函数必须是静态的函数,即不可以是类函数,否则将报错:error C3867: “XXX::XXX”: 非标准语法;请使用 “&“ 来创建指向成员的指针,

5.提供一个中文、数字、英文、特殊字符的的比较

int GetCharType(const WCHAR ch)
{
// ASIIC码值 > 127 定义为中文字符
if (ch >= '0' && ch <= '9') {
return 0;
}
else if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
return 1;
}
else if ((ch > 127)) {
return 2;
}
return 3; // 其他字符
}

bool xxxx::operator<(DeviceTreeItem* other) const
{
const std::string name1 = thisStr.toStdString();
const std::string name2 = otherStr.toStdString();
WCHAR ch1 = name1.at(0);
WCHAR ch2 = name2.at(0);
int nType = GetCharType(ch1) - GetCharType(ch2);
//数字 < 字母 < 汉字 <特殊字符
if (0 != nType) {
//qDebug() << (nType < 0);
return (nType < 0);
}
const wchar_t* wstrText = reinterpret_cast<const wchar_t*>(thisStr.utf16());
const wchar_t* wstrOtherText = reinterpret_cast<const wchar_t*>(otherStr.utf16());
int result = StrCmpLogicalW((wchar_t*)wstrText, (wchar_t*)wstrOtherText);
//qDebug() << (result == -1);
return (result == -1);
}


6. qtreeview + QAbstractItemModel使用,此时需要找到一个子项并且删除它,使用了model->match(....)函数,m_pDeviceTreeModel->match(m_pDeviceTreeModel->index(0, 0), Qt::UserRole,  QVariant::fromValue(tid), 1, Qt::MatchRecursive); 最开始没使用int hits = 1,该参数,及如下这个样子m_pDeviceTreeModel->match(m_pDeviceTreeModel->index(0, 0), Qt::UserRole,  QVariant::fromValue(tid),  Qt::MatchRecursive);导致match函数始终只搜索了start 那一层。这个函数总结一下,注意model中rowCount() columnCount()index() parent()函数正确性。

7.qtaudiooutput + bufferdevice(继承自qiodevice),qtaudiooutput和bufferdevice都正确的打开,但是bufferdevice的read函数并不会被调用,也就是qtaudiooutput不播放声音

解决:在主线程中启动qaudiooutput

分析:大概率原因应该是qaudiooutput需要一个事件循环才能正常工作,所以理论上来说应该在run中执行exec也能解决该问题,我还没有实际验证

8.renderwidget(一个继承普通widget)全屏显示后不能绘制边框,该widget会被用于sdl渲染yuv,在渲染时会设置setUpdatesEnabled(false),这是为了解决sdl会和qt一起渲染一个区域导致闪屏的问题,而且sdl没有工作时就可以正常绘制边框,调试打印paintevent都正常执行了

解决:暂未解决

分析:1.最开始想着是不是setUpdatesEnabled(false),但是我去除了该设置也没有解决此问题,