Table and image on one QTextDocument page in Qt4

I want to display a table and an image side by side. On the left side is the image and the right side of the table. I want this because the image is a reference image for the data present in the table. I want this to be in pdf format. So I use QTextDocument , QTextCursor and QPrinter to get pdf output. So, how can I display an image and a table in QtextDocument ie on one pdf page? I am using Qt 4.5.3 and Windows Xp. Any guidance regarding this is appreciated.

+4
source share
1 answer

Hi, I managed to do this. Just add a snippet if someone needs it.

 QTextImageFormat m_ReferenceImageFormat; m_ReferenceImageFormat.setWidth(525); m_ReferenceImageFormat.setHeight(450); m_ReferenceImageFormat.setName(imageFileName); m_pReportCursor->insertImage(m_ReferenceImageFormat,QTextFrameFormat::FloatRight); QTextTableFormat m_TableFormat; m_TableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid); m_TableFormat.setAlignment(Qt::AlignTop); m_TableFormat.setWidth(400); m_pReportCursor->insertTable(5,2,m_TableFormat); // Table implementation goes here.. 

Just make sure the image and the table do not overlap. Adjust the width and height accordingly. It should work fine. That's all.

+2
source

Source: https://habr.com/ru/post/1310706/


All Articles