QWidget: fix documentation for isEnabledTo(0)

It is NOT always the same as isEnabled().
Added a unittest to prove it.

Change-Id: I7717126835923e8c091249bfcdf81767c44fb5f7
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
David Faure 2014-06-06 13:53:58 +02:00 committed by The Qt Project
parent 11aaff3a57
commit a6d7e09e89
2 changed files with 13 additions and 1 deletions

View File

@ -2912,7 +2912,13 @@ void QWidget::showNormal()
This is the case if neither the widget itself nor every parent up
to but excluding \a ancestor has been explicitly disabled.
isEnabledTo(0) is equivalent to isEnabled().
isEnabledTo(0) returns false if this widget or any if its ancestors
was explicitly disabled.
The word ancestor here means a parent widget within the same window.
Therefore isEnabledTo(0) stops at this widget's window, unlike
isEnabled() which also takes parent windows into considerations.
\sa setEnabled(), enabled
*/

View File

@ -1210,6 +1210,12 @@ void tst_QWidget::isEnabledTo()
QVERIFY( !childWidget->isEnabledTo( testWidget ) );
QVERIFY( grandChildWidget->isEnabledTo( childWidget ) );
QVERIFY( !grandChildWidget->isEnabledTo( testWidget ) );
QMainWindow* childDialog = new QMainWindow(testWidget);
testWidget->setEnabled(false);
QVERIFY(!childDialog->isEnabled());
QVERIFY(childDialog->isEnabledTo(0));
testWidget->setEnabled(true);
}
void tst_QWidget::visible()