YaK
5th July 2009, 09:46
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 = 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();
}
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?
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();
}
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?