TooltipArea – the missing tooltip component of Qt Quick

Missing support for tooltips is one of the main problems when using Qt Quick to build native desktop software as discussed at other places. Qt targeted the issue by defining a tooltip property for Buttons in Qt Quick Controls, which works great but only on Buttons. Users asked to make the tooltip publicly available for other components – one year ago. But also in the coming Qt 5.5 it will not be present.

Fortunately the tooltip from Button can be borrowed easily. In contrast to other user created tooltip implementations this has the advantage that tooltips’ appearance is consistent no matter whether they are from a Button or a custom component. They will adapt the operating system’s style as much as Button.tooltip does and evolve with it.

Example usage

Add additional mouseover information to a Text:

Text {
    text: "10:28 am"

    TooltipArea {
        text: "Monday, 6th May 2015 10:28:03 am"
    }
}

Continue reading

Why valgrind reports “Uninitialised value” errors when running Google Test/Mock

Google Test is a C++ testing framework we’re using at Kullo. It creates a tiny binary that runs on a console and returns 0 or 1 depending on whether all tests succeeded or there was an error. So far so good.

Additionally we use valgrind to check for memory leaks, i.e. RAM that was allocated but not properly freed, which is an indication of programming errors.

You can do that by running your Google Test binary as follows:

valgrind --leak-check=full --error-exitcode=1 ./tests

Problem

One test resulted in a number of “Uninitialised value” errors, stating stuff like the following:

Use of uninitialised value of size 8
  at 0x677F9E1: _itoa_word (_itoa.c:180)
  by 0x67836D6: vfprintf (vfprintf.c:1641)
  by 0x683FC24: __vsnprintf_chk (vsnprintf_chk.c:63)
  by 0x683FB87: __snprintf_chk (snprintf_chk.c:34)
  by 0xA899B4: snprintf (stdio2.h:65)
  by 0xA899B4: testing::(anonymous namespace)::PrintByteSegmentInObjectTo(unsigned char const*, unsigned long, unsigned long, std::ostream*) (gtest-printers.cc:72)
  by 0xA8D1FC: PrintBytesInObjectToImpl (gtest-printers.cc:90)
  by 0xA8D1FC: testing::internal2::PrintBytesInObjectTo(unsigned char const*, unsigned long, std::ostream*) (gtest-printers.cc:112)

Continue reading

HKDF SHA-512 test vectors

As part of our internal software development, we needed HKDF test vectors using SHA-512 as a hash function.

These tests have been generated by using a python implementation of HKDF, which has been tested against the original RFC 5869 test vectors. (Check branch “generate-tests-sha512”, file “generate-tests-sha512.py” for test data generation.) The vectors have been successfully tested against a completely independent C++ implementation.

Test A

"hash"  : sha512
"IKM"   : "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
"salt"  : "000102030405060708090a0b0c"
"info"  : "f0f1f2f3f4f5f6f7f8f9"
"L"     : 42
"PRK"   : "665799823737ded04a88e47e54a5890bb2c3d247c7a4254a8e61350723590a26c36238127d8661b88cf80ef802d57e2f7cebcf1e00e083848be19929c61b4237"
"OKM"   : "832390086cda71fb47625bb5ceb168e4c8e26a1a16ed34d9fc7fe92c1481579338da362cb8d9f925d7cb"

Continue reading

Advanced FileDialog in QML

For Windows, Mac and Gnome (i.a. Ubuntu).

Update 2014-01-10

This blog post is work in progress and is adjusted with further research and commits in the sample project.

Introduction

File dialogs to open and save files have been introduced to QML applications in Qt 5.1 and are an important step to use QML not only for mobile apps but for full featured desktop applications as well.

The FileDialog integrates perfectly into QML but misses some critical features. One of them is the ability to set a filename in a save dialog. This is especially important for all kinds of downloads where the file already has a name which the user could use instead of typing in his own.

This leads to the question, how one can use nice cross-platform file dialogs, and which features do they provide.
Continue reading

Who of my contacts is already using this service?

That’s a natural question for every new user of a communication service like social networks etc. Popular examples of companies who have to deal with this question are Facebook, WhatsApp, and Instagram. A common method involves uploading the user’s address book to the service. However, this is a critical move because the service gets a lot of personal data of people who never agreed to share their data with a third party. Continue reading