Hello guys!
I need to insert a QPixmap in a QTextDocument and all I tried didnt work.
If anyone could help me. Code below:
document.setHtml(html);
if(matriz == true)
{
QRect rectpag
= impressora.
pageRect();
palette.
setColor(backgroundRole
(),
QColor(255,
255,
255));
this->ui->tab_3->setPalette(palette);
this->ui->tab_3->setAutoFillBackground(true);
QPixmap pm
= this
->ui
->tab_3
->grab
();
pm = pm.transformed(QTransform().rotate(270));
QSize tamanho
= pm.
size();
tamanho.scale(rectpag.size(), Qt::KeepAspectRatio);
painter.drawPixmap(Qt::AlignCenter, Qt::AlignHCenter, tamanho.width(), tamanho.height(), pm);
document.drawContents(&painter);
this->ui->tab_3->setAutoFillBackground(false);
}
document.print(&impressora);
QPrinter impressora(QPrinter::HighResolution);
QTextDocument document;
document.setHtml(html);
if(matriz == true)
{
QPainter painter;
QPalette palette;
QRect rectpag = impressora.pageRect();
palette.setColor(backgroundRole(), QColor(255, 255, 255));
this->ui->tab_3->setPalette(palette);
this->ui->tab_3->setAutoFillBackground(true);
QPixmap pm = this->ui->tab_3->grab();
pm = pm.transformed(QTransform().rotate(270));
QSize tamanho = pm.size();
tamanho.scale(rectpag.size(), Qt::KeepAspectRatio);
painter.drawPixmap(Qt::AlignCenter, Qt::AlignHCenter, tamanho.width(), tamanho.height(), pm);
document.drawContents(&painter);
this->ui->tab_3->setAutoFillBackground(false);
}
document.print(&impressora);
To copy to clipboard, switch view to plain text mode
Thanks a lot.
Bookmarks