Correct way to quit a Qt program?

QApplication is derived from QCoreApplication and thereby inherits quit() which is a public slot of QCoreApplication, so there is no difference between QApplication::quit() and QCoreApplication::quit(). As we can read in the documentation of QCoreApplication::quit() it “tells the application to exit with return code 0 (success).”. If you want to exit because you discovered file corruption … Read more

Should I use Singular or Plural name convention for REST resources?

For me is better to have a schema that you can map directly to code (easy to automate), mainly because code is what is going to be at both ends. GET /orders <—> orders POST /orders <—> orders.push(data) GET /orders/1 <—> orders[1] PUT /orders/1 <—> orders[1] = data GET /orders/1/lines <—> orders[1].lines POST /orders/1/lines <—> … Read more

How to package resources in Jar properly

Mark the resource folder under your project’s root folder as a “Source Folder” in Eclipse (right click on the folder, go to “Build Path” > “Use as source folder”). Then read the resources like this: InputStream is = MyClass.class.getClassLoader().getResourceAsStream(name + “.SOURCE”); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line = reader.readLine();

How to bind a TextBlock to a resource containing formatted text?

Here is my modified code for recursively format text. It handles Bold, Italic, Underline and LineBreak but can easily be extended to support more (modify the switch statement). public static class MyBehavior { public static string GetFormattedText(DependencyObject obj) { return (string)obj.GetValue(FormattedTextProperty); } public static void SetFormattedText(DependencyObject obj, string value) { obj.SetValue(FormattedTextProperty, value); } public static … Read more

Changing locale: Force activity to reload resources?

In your AndroidManifest.xml, add this attribute to your Activity android:configChanges=”locale” In your activity override onConfigurationChanged() @Override public void onConfigurationChanged(Configuration newConfig) { // refresh your views here super.onConfigurationChanged(newConfig); } https://developer.android.com/guide/topics/manifest/activity-element.html#config

Scala Programming for Android

I’ve written some basic Android applications in Scala, nothing too epic. Not being a Java programmer I was suggested to use a “treeshake”, I was explained by a friend that this strips out all the unnecessary libraries from the jar files. I have not documented it, but I found that someone else already has: http://chneukirchen.org/blog/archive/2009/04/programming-for-android-with-scala.html … Read more