PDA

View Full Version : grab() QTextEdit is different between linux and windows



world.kang
7th May 2019, 09:35
I've changed the background color of QTextEdit throught setStyleSheet().


QTextEdit tempEdit;
tempEdit.setStyleSheet( "background-color:black;" );


and render()


QPixmap resultPixmap( QSize(640, 480) );
tempEdit.render(&resultPixmap);

or grab()


tempEdit.grab().save("temp.png");


It worked perfectly at Ubuntu 18. (temp.png was saved just the way it looked)
But background color was NOT changed at windows 10. It keeps white background. never changed.

setPalette() is not what I want. I want change the currently looking style of QTextEdit.

Can I get an advice?
---
QT version is 5.12.0

world.kang
8th May 2019, 00:35
Resolved myself.
At ubuntu it's ok to to with before.


tempEdit.grab().save("temp.png");

But at windows grab should be done from viewport


tempEdit.viewport()->grab().save("temp.png");