3

Without manual intervention I would like to generate screenshots of a Qt desktop application. The screenshots should be generated when the make documentation make target is being issued. So in the source tree there are no PNG files containing screenshots but instead there are automated instructions of how to produce them.

An advantage of generating the screenshots would be that the documentation would always stay accurate. It would cope with the problem that the visual appearance of Qt widgets might change over time. Another advantage would be that screenshots for different Qt styles could be created. A Qt style is chosen by using QApplication::setStyle() or by starting the app with the -style command line option.

I guess there are be two approaches of how to achieve my goal.

  • Record all mouse events and key strokes that are needed to bring the application into the state where the screenshot is being taken.

  • Make the Qt application scriptable, and write a script that brings the application into the state where the screenshot is being taken

Is there any third-party software that could automate the first approach? Should I use QtScript for the second approach? Are there other ways of how to accomplish my goal? Are there any open source Qt applications that generate their documentation screenshots in their build system?

Erik Sjölund
  • 10,690
  • 7
  • 46
  • 74
  • Take a look at Squish. It designed for making auto-tests and it supports Qt applications. You may create a script that will doo all necessary work. – Dmitry Sazonov Dec 13 '14 at 14:16
  • I found some Squish documentation: [How to Use the Qt API](http://doc.froglogic.com/squish/latest/ugs-qtapi.html). I also noticed that Squish is not open source. This [price list](http://www.froglogic.com/squish/gui-testing/prices-and-licensing/named-user-licensing.php) mentions 6900 € for two named persons. Are there any open source alternatives around? – Erik Sjölund Dec 14 '14 at 07:06
  • If money is a ploblem - you may write your own solution. Some hints for making screenshots: 1. Use `QScreen::grabWindow`. 2. In OS X you could not grab multi monitors in one call - you should grab each screen separately. 3. Don't forget about device pixel ratio. – Dmitry Sazonov Dec 15 '14 at 09:17
  • 1
    Thanks for the screenshot tips, although I haven't investigated this further. Another thing; I just found out about the MIT-licensed software [sikuli](http://www.sikuli.org/) that uses image recognition to automate interactions with a graphical user interface. I haven't tried it, but it looks interesting. – Erik Sjölund Jan 01 '15 at 10:10
  • 1
    I also found this related stackoverflow question: http://stackoverflow.com/questions/20234421/object-level-non-pixel-dependent-automation-for-qt-based-guis It's about mouse click and key press automation of a Qt app, without the need to rely on image recognition. – Erik Sjölund Jan 01 '15 at 10:20

0 Answers0