Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Insert QPixmap in QTextDocument
Forum Updated to NodeBB v4.3 + New Features

Insert QPixmap in QTextDocument

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 848 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • guidupasG Offline
    guidupasG Offline
    guidupas
    wrote on last edited by
    #1

    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.

    Att.
    Guilherme Cortada Dupas

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved