[GH-ISSUE #175] How would I access Properties.Settings from QML? #112

Open
opened 2026-05-05 11:05:21 -06:00 by gitea-mirror · 6 comments
Owner

Originally created by @bountifulellie on GitHub (Dec 2, 2019).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/175

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

Originally created by @bountifulellie on GitHub (Dec 2, 2019). Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/175 I've tried registering Properties.Settings as a type, but that didn't work.
Author
Owner

@pauldotknopf commented on GitHub (Dec 2, 2019):

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

<!-- gh-comment-id:560503932 --> @pauldotknopf commented on GitHub (Dec 2, 2019): I'm not following. Can you post some snippets of what you are doing?
Author
Owner

@bountifulellie commented on GitHub (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.

<!-- gh-comment-id:560524855 --> @bountifulellie commented on GitHub (Dec 2, 2019): OK. In my Program.cs file I have this: ```cs Qml.Net.Qml.RegisterType<AppModel>("Desktop"); Qml.Net.Qml.RegisterType<Properties.Settings>("Desktop"); ``` In Main.qml, here's the relevant code: ```js 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.
Author
Owner

@pauldotknopf commented on GitHub (Dec 2, 2019):

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

<!-- gh-comment-id:560529713 --> @pauldotknopf commented on GitHub (Dec 2, 2019): Property names are converted to camalCase in QML. Try ```default.serverIp```.
Author
Owner

@bountifulellie commented on GitHub (Dec 2, 2019):

Doesn't work, same TypeError as before.

<!-- gh-comment-id:560540986 --> @bountifulellie commented on GitHub (Dec 2, 2019): Doesn't work, same TypeError as before.
Author
Owner

@pauldotknopf commented on GitHub (Dec 2, 2019):

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.

<!-- gh-comment-id:560541747 --> @pauldotknopf commented on GitHub (Dec 2, 2019): 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.
Author
Owner

@bountifulellie commented on GitHub (Dec 2, 2019):

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

<!-- gh-comment-id:560543320 --> @bountifulellie commented on GitHub (Dec 2, 2019): It is a new-able class with no ctor params, and it is set to public.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/qmlnet#112
No description provided.