QT -- 对数据的判断(总结)

一、判断Mat是否为空

if(img.empty())return -1; //是否加载成功

if(!img.data)return -1;//判断是否有数据

二、判断QImage、QPixmap是否为空

if(m_currentImage.isNull()) return; 

三、QString判断空

isEmpty

Returns true if the string has no characters; otherwise returns false.

 QString().isEmpty();            // returns true
 QString("").isEmpty();          // returns true
 QString("x").isEmpty();         // returns false
 QString("abc").isEmpty();       // returns false

isNull

Returns true if this string is null; otherwise returns false.

 QString().isNull();             // returns true
 QString("").isNull();           // returns false
 QString("abc").isNull();        // returns false

 

上一篇:一个基于百度地图的桌面软件(附工程源码)


下一篇:四则运算题目生成——蔡诺文