diff --git a/src/rviz/screenshot_dialog.cpp b/src/rviz/screenshot_dialog.cpp index 947142e0f..7ef8ef164 100644 --- a/src/rviz/screenshot_dialog.cpp +++ b/src/rviz/screenshot_dialog.cpp @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include "scaled_image_widget.h" #include "screenshot_dialog.h" @@ -111,14 +113,8 @@ void ScreenshotDialog::onTimeout() void ScreenshotDialog::takeScreenshotNow() { - if (save_full_window_) - { - screenshot_ = QPixmap::grabWindow(main_window_->winId()); - } - else - { - screenshot_ = QPixmap::grabWindow(render_window_->winId()); - } + const QWidget* w = save_full_window_ ? main_window_ : render_window_; + screenshot_ = w->windowHandle()->screen()->grabWindow(w->winId()); image_widget_->setImage(screenshot_); }