浏览代码

ENH: Fix grabbing widgets on certain Qt versions

Fix a problem grabbing widgets seen with Qt 4.8.7 and Qt 5.3.2 in the
ctkWidgetsUtilsTestGrabWidget test.
Max Smolens 7 年之前
父节点
当前提交
074ab24940
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      Libs/Widgets/ctkWidgetsUtils.cpp

+ 2 - 1
Libs/Widgets/ctkWidgetsUtils.cpp

@@ -48,7 +48,8 @@ QImage ctk::grabWidget(QWidget* widget, QRect rectangle)
     }
   if (!rectangle.isValid())
     {
-    rectangle = QRect(0,0,widget->width(),widget->height());
+    // Let Qt trigger layout mechanism and compute widget size.
+    rectangle = QRect(0,0,-1,-1);
     }
 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
   QPixmap widgetPixmap = QPixmap::grabWidget(widget, rectangle);