I have two separate widgets. I made a QPrintDialog and connected its paintRequested signal to my own slots of both widgets. The slots are here:
void PicWidget
::Print( QPrinter* printer
) {
cout << "PCW:P"<<endl;
QPainter* painter
= printer
->paintEngine
()->painter
();
if(!painter)
painter->begin(printer);
painter->drawText(100,100, "PICW");
painter->end();
}
void BrWidget
::Print( QPrinter* printer
) {
QPainter* painter
= printer
->paintEngine
()->painter
();
if(!painter)
painter->begin(printer);
painter->drawText(100,200, "BRW");
painter->end();
}
void PicWidget::Print( QPrinter* printer )
{
cout << "PCW:P"<<endl;
QPainter* painter = printer->paintEngine()->painter();
if(!painter)
painter = new QPainter(printer);
painter->begin(printer);
painter->drawText(100,100, "PICW");
painter->end();
}
void BrWidget::Print( QPrinter* printer )
{
QPainter* painter = printer->paintEngine()->painter();
if(!painter)
painter = new QPainter(printer);
painter->begin(printer);
painter->drawText(100,200, "BRW");
painter->end();
}
To copy to clipboard, switch view to plain text mode
But it doesn't work: only one of the methods works properly. It also writes that two QPainters are working at once. How can i solve the problem?
Bookmarks