Issue
I have a QTabWidget with different tabs. I want to take a screenshot of a hidden tab.
I found out how to create a screenshot of the tab if it's selected now. The problem is that I want to be able to do that even if another tab was selected.
Solution
The solution was very simple in the end, I hope it would help someone if he needs to.
To capture a screenshot of a widget you have in your application, even if it's not currently visible. For example if you have a number of tabs in your QTabWidget:
# tabs_hash is a dictionary of the widgets we have in the QTabWidget,
# or any widget we have in the application we want to print
for name in tabs_hash:
file = f'{name}.jpeg'
tabs_hash[name].grab().save(file)
Answered By - Kamil.Khoury
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.