Saturday, December 21, 2013

How to move Android SDK and NDK to a different location in Windows

Today, I've encountered the problem with using Android SDK with Qt Creator. The only message I got is "C:\Program" is not recognized as an internal or external command, so I've figured that the cause of this issue are spaces in the the path (C:\Program Files\Android\).

The moving process is very simple:


First, move your SDK directory into the destination folder (I will move entire Android directory to the root of C:\ drive, so my Android SDK path will look like C:\Android\android-sdk).

If you have only SDK, moving it is usually enough! However, if you have NDK installed, the next thing is to update you environment variables. Open Command Prompt and type control.exe sysdm.cpl. Open tab Advanced and click on Environment Variables.... Find ANDROID_NDK_ROOT variable, click Edit, and change it to reflect the new path (C:\Android\android-ndk in my case). Close all dialogs (by clicking the OK button) and you're ready to go!

Sunday, April 21, 2013

make_unique in C++14


make_unique

One of the smallest additions is actually great in its impact. It’s make_unique:
  1. auto u = make_unique<some_type>( constructor, parameters, here );
The reason make_unique has important impact is that now we can teach C++ developers to mostly never use explicit new again. In C++11 we already could teach to never use raw pointers and explicit delete again, except in rare cases that are hidden inside a class in order to do something like implement a low-level data structure. However, we could not teach to never write new because although make_shared was provided to create a shared_ptrnewwas still needed to create a unique_ptr. Now, instead of “new”, write make_unique or make_shared.
With draft C++14, we can say simply: Don’t use raw pointers, new and delete, except rarely when implementing low-level data structures. Allocate with make_unique or make_shared, use weak_ptr where appropriate to break cycles, and don’t worry about dangling pointers in C++ again.


From http://isocpp.org/blog/2013/04/trip-report-iso-c-spring-2013-meeting

Sunday, April 14, 2013

Difference between NUL and NULL in C

From "Expert C programming - Deep C secrets" book:

The one "l" NUL ends an ASCII string,
Two two "l" NULL points to no thing.

If you check your include files, you will see definition of null as

#define NULL ((void*)0)

while NUL is first symbol in ASCII table (with value of 0).

Scrolling QScrollArea causes other widgets flickering

Today I've experienced a problem with QScrollArea which was placed besides another widget, like this:

 ________________    ______________
|                |  |              |
|                |  |              |
|                |  |              |
|                |  |              |
|   QWidget      |  |  QScrollArea |
|                |  |              |
|                |  |              |
|                |  |              |
 ----------------    --------------

Now, when my QScrollArea was scrolled into left, that caused part of QWidget that was overlapping with QScrollArea content to flicker.

To avoid this behavior, before scrolling (I am scrolling QScrollArea with buttons, but I guess connecting to the sliderPressed() and sliderRelased() of horizontalScrollBar and verticalScrollBar() should do the trick), you need to hide QScrollArea: