How to mount a local folder as a drive in Windows

I have been working remotely for a couple of years and, although I do not intend to open a remote working series, I would like to share a small change that I made in my system to better adjust to that situation and to speed up my day to day. It is no secret but it still helps those of you who have had to switch to remote working.

Our compilation workflow includes continually working with repositories (where you see the benefits of using a distributed version control system like Git), and downloading data from network drives, which we have mounted as drives. In addition, our daily work includes continuously consulting files in these units. All these accesses can be …

Continue Reading →

[Nano-post] Qt, moc and pre-compiled headers

If your Qt project has the following characteristics (all):

  • uses pre-compiled headers,
  • is compiled in Visual Studio,
  • and uses Qt / MSBuild based compilation

You may find that the files generated by the Qt moc’ing tool do not compile correctly because the stdafx.h file is not found (orpch.h, or whatever the name of your precompiled header file is).

Remember that these moc’ed files are generated by Qt from (normally) .h files that have a class with theQ_OBJECT macro. For example, the moc_Header.cpp file is generated for theHeader.h file.

It is possible to solve this problem easily by entering in the configuration of the header files and forcing the inclusion of the pre-compiled header file:

Continue Reading →

Expressive strings to bool conversion

When storing and retrieving values from a JSON, XML or any other data notation, it is common to find the need to convert boolean to strings and vice versa. In general terms, it is not a complicated operation, and we will surely have a couple of help functions similar to the following:

Now, suppose that, to facilitate the reading of the file and to be more expressive in its content, instead of "true " and "false", we choose "yes" / "no" for some cases , "show" / "hide" for others, "enabled" / "disabled" in a few, etc. Our functions are then a bit more complicated:

The interface of the new string2bool obviates thefalse_str for simplicity: if it is …

Continue Reading →

Let’s focus on… the focus

Today we will talk about three particular cases in which it is convenient to alter the default behavior that some Qt widgets have when receiving the focus.

Brief introduction

For those who do not know what the focus is, basically it indicates which widget will receive the most important input events (such as keyboard events), and is usually represented by highlighting edges or some type of contour. The focus can usually be obtained by clicking on the widget or by repeatedly pressing the TAB key, although this depends (in jargon Qt) on the [focus policy (focus policy)] ( qt.html # FocusPolicy-enum) that the widget has.

Select all text when displaying the form

The simplest case is to select …

Continue Reading →

Navigating the code in a quick way (part I)

As it is usually said, writing code is not the only thing a programmer does, a programmer read a lot of code. In addition, most of that code has not been written by us. No, not even in those projects in which we are the only developer. How many of you remember all the code, with its most obscure corners, explanations and edge cases, that you have written in the last… 6 months? 4 weeks? 5 days? last Friday? The normal is to solve problems, refactor code, do better, add new features, document them… and the normal is not to remember everything too! I do not say to forget everything, but it is normal that we forget parts, the exact …

Continue Reading →

HeaderFiles is now bilingual!

After some days of work (and help from Google Translate), I am glad to announce that HeaderFiles becomes bilingual. Although my mother tongue is Spanish and I believe that programming divulgation in such language is important, it is also true that many times even Spanish-speakers google information in English. For this reason I have decided to publish in both languages so the information reaches as many people as possible.

As always, I am all ears to suggestions of style, writing, spelling, grammar, etc. in English (and Spanish of course). You can send me your comments on Twitter: @carlosbuchart.

Continue Reading →