Question: How can I open the location settings from android via Qt? 

I have already tried this and I can open the settings successfully, but not the location settings: 

```
QAndroidJniObject intent("android/content/Intent","()V");
    if ( intent.isValid() )
    {
        QAndroidJniObject param1 = QAndroidJniObject::fromString("com.android.settings");
        QAndroidJniObject param2 = QAndroidJniObject::fromString("com.android.settings.Settings");

        if ( param1.isValid() && param2.isValid() )
        {
            intent.callObjectMethod("setClassName","(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;",param1.object<jobject>(),param2.object<jobject>());

            activity.callObjectMethod("startActivity","(Landroid/content/Intent;)V",intent.object<jobject>());
        }
    }

```

I even have changed the param2 to "android.settings.LOCATION\_SOURCE\_SETTINGS" as it is written on the Android Developer page - but without any success. 

Does anybody know how to do that?
Thanks!

Answer: 
Instead of the standard `Button`, use the following when you need that behavior 

```
public class NonSelectableButton : Button
{
    public NonSelectableButton()
    {
        SetStyle(ControlStyles.Selectable, false);
    }
}

```

**EDIT:**
Here is a little test proving that it's working 

```
using System;
using System.Linq;
using System.Windows.Forms;

namespace Samples
{
    public class NonSelectableButton : Button
    {
        public NonSelectableButton()
        {
            SetStyle(ControlStyles.Selectable, false);
        }
    }

    static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var form = new Form();
            Control[] controls = { new TextBox(), new TextBox(), };
            Button[] buttons = { new NonSelectableButton { Text = "Prev" }, new NonSelectableButton { Text = "Next" }, };
            foreach (var button in buttons)
                button.Click += (sender, e) => MessageBox.Show("Button " + ((Button)sender).Text + " clicked!");
            int y = 0;
            foreach (var item in controls.Concat(buttons))
            {
                item.Left = 8;
                item.Top = y += 8;
                form.Controls.Add(item);
                y = item.Bottom;
            }
            Application.Run(form);
        }
    }
}

```

**EDIT2:**: To apply the solution, you need to do the following: 

(1) Add a new code file to your project, call it NonSelectableButton.cs with the following content

```
using System;
using System.Linq;
using System.Windows.Forms;

namespace YourNamespace
{
    public class NonSelectableButton : Button
    {
        public NonSelectableButton()
        {
            SetStyle(ControlStyles.Selectable, false);
        }
    }
}

```

(2) Compile the project  

(3) Now the new button will appear in the control toolbox (at the top) and you can drag it on a form **instead** of a standard button.
The best I could work out for stopping all buttons responding to the space-bar is this:

**NB: It is a bit of a hack**:

Set your form's `KeyPreview` property to `true`.

Then add this code to the form's `KeyPress` event:

```
private void Form1_KeyPress(object sender, KeyPressEventArgs e) 
{
   if (this.ActiveControl is Button
   && e.KeyChar == (char)Keys.Space) 
   {
      var button = this.ActiveControl;
      button.Enabled = false;
      Application.DoEvents();
      button.Enabled = true;
      button.Focus();
   }
}

```

And to stop a control from getting focus when tabbing, simply set the button's `TabStop` property to false.