qt
Appropriate technique to create new object by user on front end in Qt
I'm creating an app that uses qml in the front end to create a new object onclicked. Is the appropriate way to go about this is to create a QOBJECT helper class that will solely serve to instantiate new objects of my other class? Edit: I am wanting to create a C++ object from the front end with qml. I am not creating a qml object. So, if I click my button, C++ instantiates a new object. That is why I ask if I need to create a specialized QOBJECT class that has a public signal method solely to create new objects of my other class. Or should I only have one class that can instantiate new objects of itself using a pointer?
The most efficient solution is to employ a singleton. It will avoid to overhead of the factory object lookup, and it will not associate the created object with any particular state, which is known to play tricks with object lifetime. Additionally, if you create the QML object from C++, you can avoid a fair amount of memory usage bloat. You can also have a C++ object as a singleton: qmlRegisterSingletonType<YourSingleton>("Module", 1, 0, "Singleton", singletonFactoryCallback);
Related Links
Fixed sized scroll area with layout.
qt rotated image -> polygon
selectedRows() in Qml TreeView with ExtendedSelection is one step behind
ComboBoxStyle QML QT Label not working
Connection of pure virtual signal of interface class
Retain focus of QtWidget on close of QFrame
How to set tab order with promoted widgets?
Windows 10 h264 videos with QMediaPlayer
codesign gives no identity found error
Automator & ffmpeg: Create video from .png image sequence in folder
PyQt: Add icon to right side of QListWidget item
Qt. Rotation objects
What 'model' am I getting in my ListView delegate?
How to manage Focus with States in my custom QML component?
in QT I Can't create project with a Kit
Youtube video not playing in qt webview