marcelpetrick
Qt: libpng warning (exception) about wrong color profile (sRGB)
Problem: libpng warning: iCCP: known incorrect sRGB profile
When debugging Qt applications which load some PNG as icons at startup, it could be annoying to continue with the debugger for each thrown exception.
So, let us fix them.
Invoking $ mogrify *.png in the icon directory will fix them.
How to get mogrify? Install imagemagick.
Either manually or on macOS via homebrew: $ brew install imagemagick
libPNG in version 1.6 has to be at least installed: $ convert -list format | grep PNG
How to force Win10 to use certain interface for “browsing”
Problem was that before only two ethernet-interfaces were active. One for the company-intranet (which was gateway for internet) and the second one for some device connection.
After adding some 10 GigE-interface, somehow all DNS-requests were first routed via that interface. Which lead to a delay of 3-4 seconds for loading pages.
Can be fixed via setting a lower metrik to the interface, which influences the routing-table: “network- and sharing option > the specific adapter > “IPv4” > “Settings” > “Advanced settings” > bottom “metric” from “automatic metric” to some lower value. Usually it should be 25, I set 13.
You can check via CMD: $ route print for the current value. The used Gateway should have the lowest metric.
EFI partition on usb-stick: Win10 not able to remove it with the diskmanager
Regular formatting/diskmanager can not handle it.
Additional tools were not available/allowed to install.
So the trick was to use “diskpart” (CMD ..):
- then “list disk”
- “select disk1” (or the one medium which contains the partition(s))
- “clean”
- confirm the error
Then use a regular tool to create a new partition.
Qt: Error: Not a signal or slot declaration
This error is too ‘good’ to be just put into “Today I learned”.
While adapting some unit-testing-code for one of the classes, I received from minGW a error stating:
1 2 3 |
Output ------ C:/Repos/repoName/filename.h:23: Error: Not a signal or slot declaration |
What is the problem? The member-declaration looked totally valid.
Until I realized I had removed the (now commented) “private”-statement and therefore the pointers were seen by the MOC as signals/slots. Which they weren’t!
1 2 3 4 5 6 7 8 9 |
.. private Q_SLOTS: void initTestCase( void ); void cleanupTestCase( void ); //private: classA* _serialPort = nullptr; classB* _flickerSensor = nullptr; .. |
Shame on me :’)
Win: run script after executing the VisualStudio-environment-command
Problem: our CMakeLists.txt contained one specific variable which is just set via the VisualStudio-command-prompt. But I did not want to start that cmd, then execute our “start IDE”-script from there. Naa, too much clicks 😉
Copy this as bat-file to the directory where the qtcreator.bat would be.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
@echo off rem inspiration from https://www.codeproject.com/Questions/541856/Batchplusfile-3aplusOpenpluscmd-2cplusrunplusVSplu set workingDir=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\ set vs=VsDevCmd.bat rem execute the VS build enviroment cd %workingDir% call %vs% rem go back to current directory cd /d %~dp0 qtcreator.bat |
python: maximum size of certain containers
Getting the 64 bit version is quite important. Still don’t get it why for Win the 32 bit one was preferred ..
1 2 |
import sys print(sys.maxsize) |
32 bit: 2147483647 (elements)
64 bit: 9223372036854775807 (elements)
20190711 edit: even if the container could keep that much elements – remember that [Boolean] is 24 Byte (intead of one Bit) in vanilla Python. Means: if you run out of real memory, then MemoryError :/
Education 2019
Time to reveal the plans of the supervised education for 2019: today my course from the “Volkshochschule” (adult evening school?) for “machine learning with Python” starts (you remember the course for advanced Python I did in May 2018 and which I backep up by doing exercises for Project Euler and “365 days coding challenge”? link ). I am really, really looking forward and am eager to learn 🙂
After this is finished in June my course for basic introduction to Mandarin will start (not a ‘computer’ language, but an interesting one) in addition to my daily Duolingo-exercises for this upcoming lingua franca (from my POV). Will be a challenge, especially the spoken version with its intonations.
Last but not least: on week ago I participated in a course as first responder for emergencies (at work).
And I still plan to do a professional certified course for software architecture (the big picture) in autumn.
edit: repo with a apart of the notes from the machine learning with Python-course are at Github.
Heltec WifiKit 8
Ordered myself two Wifikit8 Esp8266-based boards from Aliexpress.
Received them after roundabout two weeks and now the fun can start.
With the integrated 0.91″ display (128×32 Pixel) a lot of effort for integrating some display or LEDs can be saved. Just noticed that a LiPo-charger is built-in as well, wow. For 4,50 € not a bad choice. But I am not 100% sure if this is the real device or some copycat – nevertheless: in the end the functionality matters.
First project-idea is to create an extended and verifyable version of the random-reviewer. With display of the currently chosen person, a big buzzer-button as trigger and a web-interface for those who doubt the true randomness ..
good guides:
- https://robotzero.one/heltec-wifi-kit-8/ – hints for the board itself
- https://www.bastelgarage.ch/heltec-wifi-kit8-board-esp8266-32mbit – hints for the board itself
- https://github.com/olikraus/u8g2/wiki/u8x8reference#drawstring – library for drawing text; works well
Qt: clean includes
(I’ve decided to follow a more agile workflow: instead of creation a “one post covers the whole topic”-post, to post also updates for each step. Article will be therefore edited while “doing”)
Last week I’ve cleaned Qt-includes for a larger project. Like #include
to #include
how it should be. With proper indirection, so that the Qt-library handles how and where the class is implemented.
A colleauge raised the question, why not use #include
to be even more precise and to see the used module directly (needed for the CMakeLists or qmake).
First step: identify all used Qt-includes
1 2 3 4 5 6 |
$ git grep "include <Q" | cut -d : -f 2 | sort -u # include <QApplication> # include <QAtomicInt> # include <QDebug> # include <QFileDialog> # include <QHBoxLayout> |
Greps all includes starting with an uppercase Q; then split the result at the “:”; then sort und make it unique
Second step: create a replacement-list and a (python?) script which does this for all .h/.cpp-files
tdb
C++: proper init for double/float and the proper check
Problem was that I initialized some doubles with 0.0 and then hoped that the imported values are assigned, which does not happen always. So a check was needed. But checking if(0.0 == x)
is a really bad idea. MinGW will tell you too (as other compilers).
So I was searching for a proper way to check against 0.0. And then I found a better idea: initialize with NaN and use the standard-check against this. Much better!
1 2 3 4 5 6 7 8 9 10 |
#include <limits> .. // init them with NaN to prevent later issues double x{std::numeric_limits<double>::quiet_NaN()}; .. if(isnan(x)) { qDebug() << "uninitialized"; // todom remove return false; } |
(addendum: I know, a variant would be the best to fix the given task.)