In the following code the commented QPixmap::grab works, but is depreciated. I am trying to get QWidget::grab to work. I am wanting to grab the entire dialog so I am supplying no rect argument, wanting to use the default. I get the following error:

**C:\My Libraries\Programming\CppProj\ptest\printtest\main .cpp:16: error: cannot call member function 'QPixmap QWidget::grab(const QRect&)' without object
QPixmap pm = ArticleDialog::grab();
^
but I thought grab was static? If I replace the class "ArticleDialog" with the instance myWidget, I get the error:

**C:\My Libraries\Programming\CppProj\ptest\printtest\main .cpp:15: error: 'myWidget' is not a class or namespace
QPixmap pm = myWidget::grab();
^

What am I doing wrong?
Qt Code:
  1. #include "articledialog.h"
  2. #include <QApplication>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication a(argc, argv);
  7. ArticleDialog myWidget;
  8. myWidget.show();
  9. QPrinter printer;
  10. QPrintDialog printDialog(&printer);
  11. if (printDialog.exec() == QDialog::Accepted) {
  12.  
  13. QPainter p(&printer);
  14. //QPixmap pm = QPixmap::grabWidget(&myWidget);
  15. QPixmap pm = ArticleDialog::grab();
  16. p.drawPixmap(0, 0, pm);
  17. }
  18.  
  19. return a.exec();
  20. }
To copy to clipboard, switch view to plain text mode 
_______________________________