
Originally Posted by
Chicken Blood Machine
Your call to grabWidget() should be grabWidget(T, T->rect());
Yeah, that makes a lot more sense

Originally Posted by
Chicken Blood Machine
Also, drop the setViewport() and setWindow() stuff.
Done.
Thus far, nothing is yet changing 
To re-iterate, this is what I have now:
void formMainApp::menuFilePrint()
{
//No reason for color in this dialog
p.setCreator("TIRdb");
p.setDocName("TIRdb Printout");
{
QModelIndexList MIL = ui.treeViewSQLList->selectionModel()->selectedIndexes();
for(QList<QModelIndex>::iterator i = MIL.begin(); i != MIL.end(); ++i)
{
formTIR * T = TIRTree->findTIR(*i); //TIRTree is my model, findTIR returns the dialog
if(!T) //Some elements in the tree do not have dialogs attached to them
{
continue;
}
if(qpm.isNull())
{
qDebug() << "Failed to capture the dialog for printing";
return;
}
qpm.scaled(p.pageRect().width(), p.pageRect().height(), Qt::KeepAspectRatio);
painter.begin(&p);
painter.drawPixmap(0, 0, qpm);
painter.end();
}
}
}
void formMainApp::menuFilePrint()
{
QPrinter p;
p.setColorMode(QPrinter::GrayScale);
//No reason for color in this dialog
p.setCreator("TIRdb");
p.setDocName("TIRdb Printout");
QPrintDialog qp(&p, this);
if(qp.exec() == QDialog::Accepted)
{
QModelIndexList MIL = ui.treeViewSQLList->selectionModel()->selectedIndexes();
QPainter painter;
for(QList<QModelIndex>::iterator i = MIL.begin(); i != MIL.end(); ++i)
{
formTIR * T = TIRTree->findTIR(*i); //TIRTree is my model, findTIR returns the dialog
if(!T) //Some elements in the tree do not have dialogs attached to them
{
continue;
}
QPixmap qpm = QPixmap::grabWidget(T, T->rect());
if(qpm.isNull())
{
qDebug() << "Failed to capture the dialog for printing";
return;
}
qpm.scaled(p.pageRect().width(), p.pageRect().height(), Qt::KeepAspectRatio);
painter.begin(&p);
painter.drawPixmap(0, 0, qpm);
painter.end();
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks