Insert QPixmap in QTextDocument



  • Hello guys!

    I need to insert a QPixmap in a QTextDocument and all I tried didnt work.

    If anyone could help me. Code below:

    @
    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);
    

    @

    Thanks a lot.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.