QRect rect(0, 0, 0, 0); // An empty rectangle if (rect.isEmpty()) { qDebug() << "The rectangle is empty!"; } else { qDebug() << "The rectangle is not empty."; }
QRect rect(10, 20, 30, 40); // A non-empty rectangle if (rect.isEmpty()) { qDebug() << "The rectangle is empty!"; } else { qDebug() << "The rectangle is not empty."; }Output: The rectangle is not empty. Both examples use the Qt library, which should be installed and included in the project for the code to work.