How do I get application output from a Qt Creator plugin? - qt

I'm writing an plugin for Qt Creator that will use the application output for a secondary reason (real-time graphical display of data). However, I've run into the problem of getting the application output. I don't wish to steal the output completely, just duplicate it. However, being able to filter what the debugger gets would be nice but not a requirement.
In case you are wondering, I'm trying to avoid modifying existing plugins so that any update to Qt Creator won't conflict and require patching for every single new version.

Creator is a open source project and your contributions are welcome:-) So why don't you to ask for Creator to be changed? The fastest way to do that is to write a patch that implements the interfaces you want and then submit it via codereview.qt-project.org.
Adding another patch that actually uses those interfaces can help, as that makes it easier to judge whether that functionality is really needed or whether there is a better way to implement it.

Related

Qt Creator version 4.9.2: Filter output in Application Output pane

Does anyone out there know of a Qt Creator plugin that will give me the ability to filter debug output (based on a string pattern) in Applicaiton Output pane during debugging. This is a common feature in logging applications, but in many cases it's much easier to use the log from within Qt Creator.
The app I'm currently working on creates a new log file upon every launch, so using a conventional logger is not convenient for me.
Thank you!
Apparently for version 4.9.2 there is no straightforward solution to this problem other than relying on an external logger. I installed Qt Creator version 4.10.0 and it does allow filtering of the output pane.

QtCreator Designer signal/slot connections inconsistent with generated code

I'm working on a Qt project in QtCreator. The project has a dialog box with several UI elements, some of which have to be enabled/disabled according to what the user does. (i.e. If the user selects a radio button, then the form field has to be enabled.)
When I add a new signal/slot connection or delete an existing through the Qt Designer tool, the change shows up just fine in the preview. When I compile the application, though, the window still behaves exactly as it did before.
I investigated this by checking out the ui_WindowName.h file that the Qt Designer creates. Near the end of the setupUi function is a set of connect() calls. These connect() calls are consistent with the slot and signals that existed earlier today, but they do not reflect the changes I have made through Qt Designer since.
If I manually change the ui_WindowName.h file, then the UI works. But, of course, my changes get overridden if I ever try to chance anything from Qt Designer.
Even when I quit QtCreator and open it again, the Designer still shows the changed slot/signal connections while the auto-generated code does not reflect the changes.
Am I doing something wrong? Is there some way to delete whatever cache the Designer is storing or something to get things back in sync?
Thanks!
(One other thing: I'm using the stand-alone Qt Creator, not trying to develop in Visual Studio. The only other similar problem I could find on the web was from someone developing in Visual Studio, which doesn't support the automated signal/slot stuff.)
As usual, the answer is obvious once you realize it.
I moved the project in the course of working on it. There's a .pro.user file that keeps track of where the project is located. Without realizing that, I moved it along with the rest of the files.
As a result, I was editing one copy of the project and running the other.
The moral of the story: If you move a Qt project, remember to update your .pro.user file.
(Or you can just delete it. Qt Creator will prompt you to re-create it when you open the project.)

Documentation for writing GNOME Shell extensions

I've been asked to customise the layout of the GNOME 3 desktop. Apparently the way to do that is by writing an "extension".
I've managed to do some of the things I wanted to do, but I feel utterly starved of information. I cannot find any useful documentation anywhere. I've wasted entire days of my life frantically googling every imaginable search term in a desperate attempt to find useful information.
The GNOME website has hundreds of extensions for download. These are not trivial 3-liners; they're sophisticated pieces of code. It defies belief that anybody could write these without documentation explaining how to do it.
Please, can somebody tell me where the actual documentation is? So far, the best I've managed to do is take apart existing extensions trying to track down the magic command that does the specific bit I'm interested in. (Not an easy task!)
Command names, object paths, example programs, anything would be helpful!
I have recently dug into it myself. The documentation is usually sparse or outdated. Here are some sources which helped me to get started (and through development):
Basic Stuff
Step-by-step tutorial (Gnome 3.4)
Unofficial documentation for the JavaScript bindings of many libraries
The sources of the gnome-shell's JavaScript bindings
Explanation of the St (Shell Toolkit) Ui-Toolkit components.
Some unofficial guidelines to get your extension on extensions.gnome.org
Since the documentation is nearly unavailable (or up to date), you'll need to do a lot of source-reading. I linked the gnome-shell sources above (the JavaScript part) which is a good start when diving into parts that are not covered by the In-official documentation (which is the most complete thing you'll find).
What's also particular helpful is checking extensions.gnome.org for extensions which do similar things to what you want to create, and look at their sources (most of them are open-source on GitHub or Bitbucket. You can also install them and find the sources under ~/.local/share/gnome-shell/extensions/).
When searching for something to use or more documentation on a particular function, you can also consult manuals for bindings in different languages (thought the parameters and return-values might not match).
Last but not least, here is some debugging advice:
LookingGlass is not particularly helpful. It only shows one line of an exception (the description) and only if they occur at startup time (when your extension is first started).
For full StackTraces and runtime-exceptions, consult the ~/.xsession-errors-file. It might be very long and bloated. I use this handy script to read it:
# Grabs the last session-errors from the current X11 session.
# This includes full Stack-Trace of gnome-shell-extension errors.
# See https://live.gnome.org/GnomeShell/Extensions/StepByStepTutorial#lookingGlass
tail -n100 ~/.cache/gdm/session.log | less
Note that since Gnome 3.6, if you are using gdm as display manager, the current session log is the file ~/.cache/gdm/session.log.
On some newer distros using systemd, you can get the error logs with:
journalctl -f /usr/bin/gnome-session
For debugging the prefs-part of your extension, you can launch the preferences by using the gnome-shell-extension-prefs-tool from a terminal, to see any exception-output on the console (you can also call the tool like gnome-shell-extension-prefs [uuid], to directly show your extensions preferences).
Since there is currently no real way of debugging with breakpoints (there is, but it's tricky), you can log on the console for quick checking, use the print()-function. You will see the output as mentioned above (either in the sessions-error file or on the terminal when starting gnome-shell-extension-prefs-tool).
Although it might be a little hard to get into it, the extension framework is quite powerful. Have fun!
I wrote a Blog-Post with somewhat greater detail, which can be found here: Making Gnome-Shell Extensions
An extensive list of references can be found on the Gnome Developer - API Reference page.
I used the following for my extension, but your use may vary:
GTK+ 3
GTK+ is the primary library used to construct user interfaces in GNOME applications. It provides user interface controls and signal callbacks to control user interfaces.
GDK 3
GDK is an intermediate layer which isolates GTK+ from the details of the windowing system.
Clutter
Clutter is a GObject based library for creating fast, visually rich, graphical user interfaces.
GObject Introspection
GObject Introspection is striving to provide a middleware layer between (GObject based) C libraries and language bindings.
Shell
Shell Reference Manual
St
St - Shell Toolkit - is the GNOME Shell's custom Clutter-based toolkit that defines useful actors. Some of these actors, such as StBoxLayout and StBin implement various layout options.
Icon Theme Specification
This freedesktop.org specification describes a common way to store icon themes.
NOTE: These last two are very helpful in finding visual element parameters!
PyGTK
PyGTK is GTK+ for Python. This reference contains a chapter for each Python PyGTK module (that corresponds to the underlying GTK+ library) containing the class descriptions.
PyGObject
PyGObject is a Python extension module that gives clean and consistent access to the entire GNOME software platform through the use of GObject Introspection. Specifically speaking, it is Python Bindings for GLib, GObject, GIO and GTK+.
This reference contains a chapter for each PyGObject module containing the class descriptions.
The documentation is on:
https://gjs.guide/extensions/
For the documentation of libraries:
https://gjs-docs.gnome.org/
More details on https://gjs.guide/extensions/overview/architecture.html
The other stuff you might want to check are
https://gitlab.gnome.org/GNOME/gnome-shell/blob/main/js/ui/popupMenu.js
https://gitlab.gnome.org/GNOME/gnome-shell/blob/main/js/ui/dialog.js
https://gitlab.gnome.org/GNOME/gnome-shell/blob/main/js/ui/modalDialog.js
https://gitlab.gnome.org/GNOME/gnome-shell/blob/main/js/ui/panelMenu.js
https://gitlab.gnome.org/GNOME/gnome-shell/tree/main/js
https://gitlab.gnome.org/GNOME/mutter
You can browse under js/ for more code to be reused.
You might also want to check https://gi.readthedocs.io/en/latest/index.html
Question:
I could not find anything under https://gjs-docs.gnome.org/ except some CSS and Javascript documentation ?!?!
Answer:
You have to first enable the docs to use them. Here, you will be mainly looking for:
clutter
meta
shell
st
Create a file like:
echo '{"docs":"clutter9~9_api/clutterx118~8_api/gobject20~2.66p/meta9~9_api/shell01~0.1_api/st10~1.0_api","hideIntro":"1"}' > devdocs.json
Import this file to https://gjs-docs.gnome.org/settings
Now you will be able to visit:
https://gjs-docs.gnome.org/shell01~0.1_api-global/
https://gjs-docs.gnome.org/shell01~0.1_api/
https://gjs-docs.gnome.org/meta9~9_api/
https://gjs-docs.gnome.org/st10~1.0_api/
https://gjs-docs.gnome.org/clutter9~9_api/
https://gjs-docs.gnome.org/clutter9~9_api-actor/
Warning: The version on the devdocs.json file is hardcoded. It will be outdated in no time, so you might want to check the version. The point is - you can not access docs until you enable them.
P.S. I know, this is a mess. This is how they did it.

Is it possible to implement emacs style keybindings in all Qt programs (probably as a qt plugin)?

Gtk programs can have different keybinding themes by binding different keys to gtk signals, but afaik, qt programs cannot do that now.
Since Qt support plugins (as most of this kind of library do, and what I mean here is High Level Plugin or Qt Extension) and at least some of them (High Level Plugins) can be loaded automatically by all qt programs according to sth like ENV, is it possible to have global (Emacs or other style) keybindings (at least in all input area) using qt plugin? Or in an other word, does anyone know which kind of (High Level) plugin this should be?
My guess is a inputcontext plugin or a accessible(bridge) plugin.
For input context plugin, I wonder if this can work with input method since afaik only one inputmethod backend can be enabled at one time.
For accessible plugin, I haven't find out how to make it loaded automatically.
Thanks.
You could install an event filter to intercept key events, and use that to convert them to other events.
I think you're using the word "plug-in" in a different sense to Qt. It has various specific plugins -- for image codecs, SQL drivers, etc -- but no general-purpose "do this to all widgets" mechanism. For that, you would have to catch all the creation-points of the top-level widgets in your application and add code to install the filter for each case.
I somehow solve the problem (along with this one) using xkb, i.e. redirect C-npfbae to proper keys, although I haven't made C-d redirection compatible with terminal EOF.
I still think the problem (in Qt) can be solved with qtaccessible plugins but I haven't find out how to make that work.

Make a phone call with qt 4.6.3

I need to trigger a phone call from a Qt application. I looked to previous post without find a complete answer.
I need to make it with qt 4.6.3. I'm quite new to symbian development, I'm using the last nokiaSDK.
It MUST work ONLY on n97 and E71.
Can Anybody provide a solution?
May be a solution exec an extenal process using QProcess?
It seems like currently none of Qt APIs (including QtMobility) allows to do it. However, you can use native Symbian C++ API - CTelephony class. There are some examples showing how to make a phone call using this class. The obvious disadvantage is that it won't work on any other platform than Symbian.
You may be interested in this example: http://library.forum.nokia.com/topic/Qt_for_Symbian_Developers_Library/GUID-B4DA6005-3037-4FF8-82D5-BA748532E648.html#GUID-B4DA6005-3037-4FF8-82D5-BA748532E648. It shows how to mix Symbian C++ code with Qt code, and it also uses CTelephony, so you just need to change method call from GetPhoneId() to DialNewCall(). Don't forget to add appropriate library (etel3rdparty.lib) in your .pro file.

Resources