Hi,
i try to clip a QPicture:
Code:
This Code don't work, why?
Thank's in advance
Whitefurrows
Printable View
Hi,
i try to clip a QPicture:
Code:
This Code don't work, why?
Thank's in advance
Whitefurrows
What exactly doesn't work? And shouldn't you use QPixmap instead of QPicture?Quote:
Originally Posted by whitefurrows
Hi,
i have many problems with clip a picture and i don’t know why. This Code is a simple Example to clip a Picture. What i try to do ist hat:
Code:
void Report::printButton_clicked( const QString& html ) { QTextDocument doc; float w=533; // page width float h=754; // page height doc.setHtml(html); // Set the TextDocument's page size //int pageCount=doc.pageCount(); QPainter p; //for ( int page=1; page<=pageCount; page++){ QPicture pic; p.begin(&pic); // Start painting //QRectF view(0, (page - 1) * h, w, h); //ctx.clip = view; // page1 and page2 only for test, i wont use the loop //Page1 layout->draw(&p,ctx); //Page2 //ctx.clip = QRectF(0,h,w,h); // Set the context clip to the second page //docLayout->draw(&p,ctx); p.end(); // End painting //picList.append(pic); //} }
The picture won't clip. Picture1 is OK but picture2 ist picture1 + picture2 and picture3 is picture1 + picture2 + picture3..... I think that is a QT-Bug (v4.1.0) or you know what is wrong?
Greetings
Whitefurrows
I'm very sad, i have try a lot of hour to get it work. Please give me somebody a response. I'm greatful for everything!
Thanks in advance
I've made a little test (see attachment) and it seems that QPainter::translate() is a key to success.
You are my hero! That's great, the code work perfect. It's unbelievable how easy to do. A lot of thanks to you for that splendid help.
Best regards,
Whitefurrows