[vlc-devel] [PATCH] gui/qt: use QWidget::grab instead of deprecated QPixMap::grabWidget

Sebastian Ramacher sramacher at debian.org
Sun Mar 5 17:38:47 CET 2017


Fixes "QPixmap::grabWidget is deprecated, use QWidget::grab() instead".
---
 modules/gui/qt/dialogs/plugins.cpp | 6 ++++++
 modules/gui/qt/dialogs/toolbar.cpp | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/modules/gui/qt/dialogs/plugins.cpp b/modules/gui/qt/dialogs/plugins.cpp
index d3af829d34..9e05b08bfa 100644
--- a/modules/gui/qt/dialogs/plugins.cpp
+++ b/modules/gui/qt/dialogs/plugins.cpp
@@ -1243,9 +1243,15 @@ void AddonItemDelegate::paint( QPainter *painter,
                 progressbar->setGeometry(
                     newopt.rect.adjusted( adjustment.width(), adjustment.height(),
                                           -adjustment.width(), -adjustment.height() ) );
+#if HAS_QT5
+                painter->drawPixmap( newopt.rect.left() + adjustment.width(),
+                                     newopt.rect.top() + adjustment.height(),
+                                     progressbar->grab() );
+#else
                 painter->drawPixmap( newopt.rect.left() + adjustment.width(),
                                      newopt.rect.top() + adjustment.height(),
                                      QPixmap::grabWidget( progressbar ) );
+#endif
             }
             painter->restore();
         }
diff --git a/modules/gui/qt/dialogs/toolbar.cpp b/modules/gui/qt/dialogs/toolbar.cpp
index dc90ef50b6..bc6b547e4e 100644
--- a/modules/gui/qt/dialogs/toolbar.cpp
+++ b/modules/gui/qt/dialogs/toolbar.cpp
@@ -315,7 +315,11 @@ void PreviewWidget::paintEvent( QPaintEvent * )
     QPixmap pixmaps[3];
     for( int i=0; i<3; i++ )
     {
+#if HAS_QT5
+        pixmaps[i] = bars[i]->grab( bars[i]->contentsRect() );
+#else
         pixmaps[i] = QPixmap::grabWidget( bars[i], bars[i]->contentsRect() );
+#endif
         for( int j=0; j < bars[i]->layout()->count(); j++ )
         {
             QLayoutItem *item = bars[i]->layout()->itemAt( j );
@@ -573,7 +577,11 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent )
         if( widget == NULL ) continue;
 
 
+#if HAS_QT5
+        widgetItem->setIcon( QIcon( widget->grab() ) );
+#else
         widgetItem->setIcon( QIcon( QPixmap::grabWidget( widget ) ) );
+#endif
         widgetItem->setToolTip( widgetItem->text() );
         widget->hide();
         widgetItem->setData( Qt::UserRole, QVariant( i ) );
-- 
2.11.0



More information about the vlc-devel mailing list