本文整理汇总了C++中TextWidget::text方法的典型用法代码示例。如果您正苦于以下问题:C++ TextWidget::text方法的具体用法?C++ TextWidget::text怎么用?C++ TextWidget::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextWidget
的用法示例。
在下文中一共展示了TextWidget::text方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cast_inherit_single
/*
\req QTOPIA-78
\groups
Test case where an interface is implemented by a class which inherits a
class which implements one other interface.
*/
void tst_QtUiTestWidgets::cast_inherit_single()
{
QCOMPARE(WidgetObject::constructed, 0);
QCOMPARE(WidgetObject::destructed, 0);
QCOMPARE(TextWidgetObject::constructed, 0);
QCOMPARE(TextWidgetObject::destructed, 0);
QtUiTestWidgets::instance()->refreshPlugins();
Widget *w;
TextWidget *tw;
{
QWidget widget;
QLabel label;
w = qtuitest_cast<Widget*>(&widget);
tw = qtuitest_cast<TextWidget*>(&label);
QVERIFY(w);
QVERIFY(tw);
QCOMPARE(TextWidgetObject::constructed, 1);
QCOMPARE(TextWidgetObject::destructed, 0);
/* One or more widget objects may have been constructed while finding
* the interfaces for QLabel. However there should be exactly 2
* still existing. */
QCOMPARE(WidgetObject::constructed - WidgetObject::destructed, 2);
QCOMPARE(tw->text(), QString());
label.setText("Hi there");
QCOMPARE(tw->text(), QString("Hi there"));
}
QCOMPARE(TextWidgetObject::constructed, 1);
QCOMPARE(TextWidgetObject::destructed, 1);
QCOMPARE(WidgetObject::constructed - WidgetObject::destructed, 0);
}
示例2: cast_self
/*
\req QTOPIA-78
\groups
Test casting of a widget class which implements its own interfaces.
*/
void tst_QtUiTestWidgets::cast_self()
{
QtUiTestWidgets::instance()->clear();
QCOMPARE( TestableCheckBox::constructed, 0 );
QCOMPARE( TestableCheckBox::destructed, 0 );
Widget *w;
TextWidget *tw;
CheckWidget *cw;
{
TestableCheckBox tcb;
QCheckBox *cb = &tcb;
QCOMPARE( TestableCheckBox::constructed, 1 );
QCOMPARE( TestableCheckBox::destructed, 0 );
/* Doesn't need to be registered before cast. */
QVERIFY( w = qtuitest_cast<Widget*>(&tcb) );
QVERIFY( tw = qtuitest_cast<TextWidget*>(&tcb) );
QVERIFY( cw = qtuitest_cast<CheckWidget*>(&tcb) );
QCOMPARE( w, &tcb );
QCOMPARE( tw, &tcb );
QCOMPARE( cw, &tcb );
/* However, should still work when other classes are registered...*/
QtUiTestWidgets::instance()->refreshPlugins();
QCOMPARE( qtuitest_cast<Widget*>(&tcb), w );
QCOMPARE( qtuitest_cast<TextWidget*>(&tcb), tw );
QCOMPARE( qtuitest_cast<CheckWidget*>(&tcb), cw );
QCOMPARE( WidgetObject::constructed, 0 );
QCOMPARE( WidgetObject::destructed, 0 );
QCOMPARE( TestableCheckBox::constructed, 1 );
QCOMPARE( TestableCheckBox::destructed, 0 );
/* Use it a bit and make sure it works as expected. */
QCOMPARE( w->geometry(), tcb.geometry() );
tcb.setText("Walk the Dog");
QCOMPARE( tw->text(), tcb.text() );
tcb.setTristate(true);
cb->setCheckState(Qt::PartiallyChecked);
QCOMPARE( cw->isTristate(), tcb.isTristate() );
QCOMPARE( cw->checkState(), tcb.checkState() );
}
/* Ensure we didn't double-delete */
QCOMPARE( TestableCheckBox::constructed, 1 );
QCOMPARE( TestableCheckBox::destructed, 1 );
/* Ensure we can make another one with no problems */
{
TestableCheckBox tcb;
QCOMPARE( TestableCheckBox::constructed, 2 );
QCOMPARE( TestableCheckBox::destructed, 1 );
QVERIFY( w = qtuitest_cast<Widget*>(&tcb) );
QVERIFY( tw = qtuitest_cast<TextWidget*>(&tcb) );
QVERIFY( cw = qtuitest_cast<CheckWidget*>(&tcb) );
QCOMPARE( w, &tcb );
QCOMPARE( tw, &tcb );
QCOMPARE( cw, &tcb );
}
QCOMPARE( TestableCheckBox::constructed, 2 );
QCOMPARE( TestableCheckBox::destructed, 2 );
/* Ensure casting a null pointer has no ill effects */
w = qtuitest_cast<Widget*>( static_cast<TestableCheckBox*>(0) );
QVERIFY( !w );
QCOMPARE( TestableCheckBox::constructed, 2 );
QCOMPARE( TestableCheckBox::destructed, 2 );
QCOMPARE( WidgetObject::constructed, 0 );
QCOMPARE( WidgetObject::destructed, 0 );
}