QTextCursor cursor; if (cursor.isNull()) { qDebug() << "The cursor is null"; } QTextDocument *document = new QTextDocument(); QTextCursor cursor(document); if (!cursor.isNull()) { qDebug() << "The cursor is not null"; } QTextCursor invalidCursor(nullptr); if (invalidCursor.isNull()) { qDebug() << "The cursor is invalid"; }It should be noted that QTextCursor is part of the QtGui package.