【QT】QT问题集合

1、C++ 、Qt计算时间的方法
参考链接:https://www.cnblogs.com/m-zhang-yang/p/9449017.html
https://blog.csdn.net/chy555chy/article/details/53405072

timeGetTime的精度为ms级,必须添加Winmm.lib, 否则编译报错undefined reference;
timeGetTime可以使用GetTickCount代替(RTKLIB)

2、QT递归删除文件或者文件夹

bool MainWindow::DeleteFileOrFolder( const QString& strPath )
{
    if( strPath.isEmpty() || !QDir().exists( strPath ) )
        return false;

    QFileInfo fileInfo( strPath );

    if( fileInfo.isFile() )
        QFile::remove( strPath );
    else if( fileInfo.isDir() )
    {
        QDir qDir( strPath );
        qDir.setFilter( QDir::AllEntries | QDir::NoDotAndDotDot );
        QFileInfoList fileInfoLst = qDir.entryInfoList();
        foreach( QFileInfo qFileInfo, fileInfoLst )
        {
            if( qFileInfo.isFile() )
                qDir.remove( qFileInfo.absoluteFilePath() );
            else
            {
                DeleteFileOrFolder( qFileInfo.absoluteFilePath() );
                qDir.rmdir( qFileInfo.absoluteFilePath() );
            }
        }
        qDir.rmdir( fileInfo.absoluteFilePath() );
    }

    return true;
}

QTextStream

在使用QTextStream类的setFieldWidth函数设置占用宽度的时候切记endl也要占用字符宽度。
例如QTextStream::setFieldWidth(3)那么QTextStream<<endl就会产生一个换行符和两个空格占位。
导致下一行多出来两个空格。(切记)
所以QTextStream<<endl代码之前一定要QTextStream::setFieldWidth(1)

error: [Makefile.Debug:384: debug/RTMG_APPS_resource_res.o] Error 1

可能是你使用setWindowIcon(QIcon("widget.ico")); 没有找到ICO看看compile 输出就知道了。

Sock

http://keep.01ue.com/?pi=417481&_a=app&_c=index&_m=p
https://www.cnblogs.com/lic02891/archive/2012/11/09/2763210.html
https://www.cnblogs.com/sky-heaven/p/6840693.html

发布了146 篇原创文章 · 获赞 60 · 访问量 28万+

猜你喜欢

转载自blog.csdn.net/xiaoxiao133/article/details/94379106
QT
今日推荐