![]() javascript (*.js): automation without user interactions.There are now two different script types one can use, depending on the needs: A glimpse into our Qt Creator Scripting pluginĪs said, the new plugin is now based on the QQmlEngine, opening a wide array of new features to us. Our new scripting plugin is now based on the QQmlEngine, and now supports user interactions. It’s not possible to interact with the scriptīack to the drawing board, coming from Qt Script/javascript the natural way forward is Qt Declarative/QML.It is based on the dying Qt Script module.Lately, we reviewed the scripting plugin and checked what could be improved: This plugin is used for our Photon to Qt or MFC to Qt migrations. It’s actually way better than macros, and to be honest I now only use macros locally, I never save them anymore. Access and handling of editors (text, C++ editors). ![]() You have access to a wide range of APIs for scripting: ![]() #QT CREATOR REFACTORING PLUGIN CODE#Here is a small script commenting out the function the cursor is in, while keeping the cursor at the same position: var editor = editors.current()Įditor.gotoPosition()Īs you can see, it’s straightforward, and it has some semantic information of the code (editor.currentFunction for example). Like for macros, you can run scripts using the locator, or even assign shortcuts to useful scripts. At the time, Qt Script was still nice and shiny, so it was based on it and the scripts were written in javascript. The Scripting pluginįollowing the macro plugin, our second iteration was the creation of a plugin allowing us to write and run scripts, like you could do with Lisp and XEmacs. Though a nice step toward automation, it’s still far from perfect, as a macro doesn’t understand code semantics (it’s only user inputs), and not everything can be recorded: for example completion is not recorded in the macro, as it’s not a user input. If you want to reuse a macro between session, it’s possible to save it, call it using the locator (the rm shortcut – “run macro” – probably not really used) or even assign a shortcut. The plugin allows you to save and replay user inputs: #QT CREATOR REFACTORING PLUGIN WINDOWS#For those who know it, the name is inspired by the macro feature in Notepad++ (also a very nice editor at the time – Windows only). My first try was the creation of the macro plugin, contributed to Qt Creator in version 2.2.0. The road to automation in Qt CreatorĮven if we are using Qt Creator, we still need to automate as much as possible, particularly when doing migration projects. ![]() As much as I like XEmacs and vim (and we all know which one is the best □ ), having a real IDE makes development so much easier, and Qt Creator was adopted quickly inside KDAB. Then slightly after this migration project, Qt Creator was released. Coming from Windows and Microsoft Visual Studio 6 at the time, this was quite a new way to work for me. During the course of the migration, I spent hours writing Lisp scripts to automate some parts of the migration, some with general purpose (used everywhere), others with a very narrow focus (only used once for one file). The second one is true for everything (remember, a good developer is a lazy developer), but it’s particularly important when doing a migration, as you don’t want to rewrite all single lines in a multi-million lines application by hand.Īt that time, I was introduced to the wonderful world of XEmacs and Lisp scripting. There are several rules you have to follow when doing a migration project, but the most important ones are probably those two: You may be wondering what this has to do with automating tasks in Qt Creator, or why I have a new entry in my Qt Creator locator… keep up with me and everything will be clear shortly. Fortunately, migrations from any toolkit to Qt is something KDAB has been doing from the beginning, and has lots of experience with. My first project when I entered KDAB was the migration of a multi-million lines Motif application to Qt… feels quite scary said like that. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |