tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 0 1918ee327afb
child 30 5dc02b23752f
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the test suite of the Qt Toolkit.
     7 ** This file is part of the test suite of the Qt Toolkit.
     8 **
     8 **
  1112 
  1112 
  1113         QRect subElementRect(QStyle::SubElement se,
  1113         QRect subElementRect(QStyle::SubElement se,
  1114                              const QStyleOption* opt,
  1114                              const QStyleOption* opt,
  1115                              const QWidget* w) const
  1115                              const QWidget* w) const
  1116         {
  1116         {
  1117             return style->subElementRect(se, opt, w);
  1117             Q_UNUSED(se);
       
  1118             Q_UNUSED(opt);
       
  1119             Q_UNUSED(w);
       
  1120             return QRect(0, 0, 3, 3);
  1118         }
  1121         }
  1119 
  1122 
  1120         void drawComplexControl(QStyle::ComplexControl cc,
  1123         void drawComplexControl(QStyle::ComplexControl cc,
  1121                                 const QStyleOptionComplex* opt,
  1124                                 const QStyleOptionComplex* opt,
  1122                                 QPainter* p,
  1125                                 QPainter* p,
  1230 
  1233 
  1231     QPushButton *pb4 = new QPushButton("StyleSheet then ProxyStyle ", w);
  1234     QPushButton *pb4 = new QPushButton("StyleSheet then ProxyStyle ", w);
  1232     pb4->setStyleSheet(styleSheet);
  1235     pb4->setStyleSheet(styleSheet);
  1233 
  1236 
  1234     // We are creating our Proxy based on current style...
  1237     // We are creating our Proxy based on current style...
  1235     // In this case it would be the QStyleSheetStyle that is delete
  1238     // In this case it would be the QStyleSheetStyle that is deleted
  1236     // later on. We need to get access to the "real" QStyle to be able to
  1239     // later on. We need to get access to the "real" QStyle to be able to
  1237     // draw correctly.
  1240     // draw correctly.
  1238     ProxyStyle* newProxy = new ProxyStyle(qApp->style());
  1241     ProxyStyle* newProxy = new ProxyStyle(qApp->style());
  1239     pb4->setStyle(newProxy);
  1242     pb4->setStyle(newProxy);
  1240 
  1243 
  1246     layout->addWidget(pb5);
  1249     layout->addWidget(pb5);
  1247 
  1250 
  1248     w->show();
  1251     w->show();
  1249 
  1252 
  1250     QTest::qWait(100);
  1253     QTest::qWait(100);
       
  1254 
       
  1255     // Test for QTBUG-7198 - style sheet overrides custom element size
       
  1256     QStyleOptionViewItemV4 opt;
       
  1257     opt.initFrom(w);
       
  1258     opt.features |= QStyleOptionViewItemV2::HasCheckIndicator;
       
  1259     QVERIFY(pb5->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, 
       
  1260             &opt, pb5).width() == 3);
  1251     delete w;
  1261     delete w;
  1252     delete proxy;
  1262     delete proxy;
  1253     delete newProxy;
  1263     delete newProxy;
  1254 }
  1264 }
  1255 
  1265