Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How would I access Properties.Settings from QML? #175

Open
lempamo opened this issue Dec 2, 2019 · 6 comments
Open

How would I access Properties.Settings from QML? #175

lempamo opened this issue Dec 2, 2019 · 6 comments

Comments

@lempamo
Copy link

lempamo commented Dec 2, 2019

I've tried registering Properties.Settings as a type, but that didn't work.

@pauldotknopf
Copy link
Member

I'm not following. Can you post some snippets of what you are doing?

@lempamo
Copy link
Author

lempamo commented Dec 2, 2019

OK. In my Program.cs file I have this:

Qml.Net.Qml.RegisterType<AppModel>("Desktop");
Qml.Net.Qml.RegisterType<Properties.Settings>("Desktop");

In Main.qml, here's the relevant code:

	AppModel {
		id: model
	}

	Settings {
		id: settings
	}

	Component.onCompleted: {
		window.status = "Checking settings..."

		if (model.verifySettings()) {

		} else {
			loginDialog.open() //defined elsewhere, not relevant here
		}

		window.status = settings.Default.ServerIP
	}

The error I get after the dialog is closed is as follows: file:///C:/Users/lempamo/source/repos/lempamo/Soulseek.NET/examples/Desktop/Main.qml:71: TypeError: Cannot read property 'ServerIP' of undefined

ServerIP is a setting within Properties.Settings.

@pauldotknopf
Copy link
Member

Property names are converted to camalCase in QML. Try default.serverIp.

@lempamo
Copy link
Author

lempamo commented Dec 2, 2019

Doesn't work, same TypeError as before.

@pauldotknopf
Copy link
Member

Is Properties.Settings new-able? With no ctor params? What type/visibility is the "Settings" property.

You might have to create your own C# class that wraps it. It might be using internal keywords.

@lempamo
Copy link
Author

lempamo commented Dec 2, 2019

It is a new-able class with no ctor params, and it is set to public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants