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?
#include "articledialog.h"
#include <QApplication>
int main(int argc, char *argv[])
{
ArticleDialog myWidget;
myWidget.show();
if (printDialog.
exec() == QDialog::Accepted) {
//QPixmap pm = QPixmap::grabWidget(&myWidget);
QPixmap pm
= ArticleDialog
::grab();
p.drawPixmap(0, 0, pm);
}
return a.exec();
}
#include "articledialog.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ArticleDialog myWidget;
myWidget.show();
QPrinter printer;
QPrintDialog printDialog(&printer);
if (printDialog.exec() == QDialog::Accepted) {
QPainter p(&printer);
//QPixmap pm = QPixmap::grabWidget(&myWidget);
QPixmap pm = ArticleDialog::grab();
p.drawPixmap(0, 0, pm);
}
return a.exec();
}
To copy to clipboard, switch view to plain text mode
_______________________________
Bookmarks