@eggbertx said in Trying to create a singleton and getting LNK2019 error:
Sorry, I meant the second code block, not the first. I'm not very familiar with assertions in general, so I've never heard of Q_ASSERT.
The assertion here is only a tool to detect creating more than one instance of the class. Q_ASSERT is a Qt macro for regular debug assertions, it will be removed in release mode, so its purpose (as assertions in general) is to catch programmer errors while debugging. So if you use the class above like this:
Singleton object1;
Singleton object2; //< Here the assertion will be tripped and you can catch the error while debugging
Adding the code in the second block fixed the issue.
Do you mean the main window constructor where the connect is made? All code blocks are part of one single example, so I'd expect them to work together only. :)