marcelpetrick

Win 10: uptime with Powershell

Written by  on March 18, 2020

(I don’t care about output from the taskmanager or whatever logs. I need a processable duration without much tinkering.)

macOS: THE operating system for ~the unproductive~ artists

Written by  on March 3, 2020

It’s quite funny. 2012 I’ve used the first time macOS (or how it was called OSX) in version 10.6.8. Now Apple has reached 10.15 and there is still no proper, simple, menu-guided way to enable an file-explorer for productive use.

How to show the current path in the title of the finder:
(bash and then enter those two lines for configuration and restarting the Finder)

How to go to a known path:
Ctrl+Shift+G -> then enter the path.

The great purge

Written by  on February 24, 2020

Git is my VCS-system of choice and github most of the time the place for my publicly shared repositories.
Over the years some clutter piled up there:

  • unfinished business; projects which were started (with best intentions) and never finished
  • forked repositories, which I don’t need anymore (not sure if I will remove also those were I contributed, because then the evidence is more or less gone, or?)
  • code I am a bit ashamed right now :’) (if you have no projects were you laugh heartily about how naively you implemented them at that time, then you made no progress)

Therefore I started to check them to see if it makes sense to keep or delete them. Right now I am down to 39 and the delete-button is still hot ๐Ÿ˜‰

Find crappy Qt-includes

Written by  on February 18, 2020

Use this regular expression

to check for includes of the format

Test it here with regex101.com.

QDialogs receive NO close-event in case of closing via the ESC-key. Nice.

Written by  on February 7, 2020

At first this looked like a bug, but upon reading carefully the documentation and crawling the internet, I’ve noticed that this is
a) wanted behavior and b) I am not the first one stumbling over this issue.

So just override in the header the method for processing the QHideEvent:

And reimplement the base-class-call with the emission of a custom signal (or triggering custom functionality) for futher processing. Like:

Edit:
Another way is to connect the QDialog’s finished-signal to your signal via DirectConnection. Less code than overriding.

qobjectdefs_impl.h:72:118: error: no type named ‘Car’ in ‘struct QtPrivate::List<>‘

Written by  on February 4, 2020

Bruh, wait, what?

After rebasing a bigger feature and solving all obvious conflicts, the new build threw an error like “no type names Car”. And I am currently not working in the automotive industry!
Issue was that a commit, on which was rebased, changed ‘old’ Qt4-signal-slot-syntax (with SIGNAL/SLOT keywords; the string-based connect) to the ‘new’ Qt5-version (typed and verifyable from the compiler). And one of the slots had a default parameter. This is not allowed, except you squish a lambda as intermediate layer.

A bit more insight: Qt-docs.

edit: One of the earlier error-messags also hinted out what could be the culprit, but “no type named Car” is more funny ๐Ÿ˜‰

Localisations

Written by  on January 24, 2020

The Qt framework offers a quite nice and convenient way to localize your application.
Not only how to mark inside the code translateable strings (tr(..)), but also that the translation-mappings are human-readable xml-format files (*.ts), but also their own tool to do the translation (Linguist). Linguist is quite helpful for translator who sometimes also have to have a look at the “what would you get with that translation of different size inside the widget”-result (more or less: WYSIWYG).

Noticed today some flaws in the localisation of MTuner (nice memory profiler) and offered some help.
This is what I love about OSS: you don’t just take, but can also lend a helping hand and improve the quality ๐Ÿ™‚

QtCreator: add online-help if the SDK is not coming from an official package

Written by  on January 1, 2020

challenge:

having some Qt-SDK without help files. Using help inside a browser is possible, but cumbersome. and local help would be nice for quick parameter-checks.

solution (edited):

Found also the official docu at: http://download.qt-project.org/online/qtsdkrepository/windows_x86/desktop/qt5_5121_src_doc_examples/qt.qt5.5121.doc/ as 7z-archive.

Then add it via QtCreator > Tools > Options > Help > Documentation > “add the QCH files”.

QtCreator: SpellChecker – how to set up

Written by  on December 22, 2019

The plan is to use the spellchecker from https://github.com/CJCombrink/SpellChecker-Plugin
Let’s be honest: it is quite hard to extract the needed information for a proper setup of the spellchecker. I took me on first try several guesses, which files to download, where to put them and how to configure the dictionary.
Since the process is a bit tricky, my two cents:

  • download the current version for Win10 x64 from this page: https://github.com/CJCombrink/SpellChecker-Plugin/releases (currently “SpellChecker-Plugin_v2.0.5_x64.zip”)
  • extract
  • copy&paste the two folders “bin” and “lib” into the current QtCreator 4.11-directory (it has to be that version 4.11 else the plugin fails to load!): for me this is “C:\Qt\Tools\QtCreator”)
  • download the proper .aff and .dic files for the dictionary from: https://cgit.freedesktop.org/libreoffice/dictionaries/tree/en – for me “en_US”
  • start QtCreator and you should have under “tools > options” a new entry for “SpellChecker” … configure there the dictionary-usage
  • restart QtCreator (again!)
  • done ๐Ÿ™‚

Qt: custom-class and specialities for QVariant and QSettings

Written by  on December 11, 2019

While implementing some custom-class (C++17; Qt5.12) some specialities became (painfully) noticeable.
The guide at the Qt-source is quite well written.

  • ctor, copy-ctor and dtor are all required and have to be public
  • add Q_DECLARE_METATYPE(CustomClass)
  • QDebug-stream-operator in case of simple debugging-messages
  • if the QVariant-version of the CustomClass shall be written to QSettings, then implement also the two streaming operators: << and >> (else crash with Assert “unable to save type”): howto