'What is the best way to determine if the QTextEdit in my QT app is empty or not?

there's a text editing widget in my QT Widget application. My menu item checks to see if the text edit below is empty. Thus, I'm trying to create a function that checks and returns true/false depending on the situation. Can anyone help me?



Solution 1:[1]

Here's a simple way to do it (illustrated with a function, for clarity):

bool IsTextEditEmpty(const QTextEdit * myTextEdit)
{
   return myTextEdit->document()->isEmpty();
}

Solution 2:[2]

There is no need for any function QML TextEdit has length property, simply reading this property and evaluating as bool will return true if TextEdit has non-empty text and false on empty text.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeremy Friesner
Solution 2 Octopussy