QML and Own C++ Object/Plugin



  • Hi;

    I wrote my own plugin and object. Problem is, C++ object's parent always null... Why ?

    In QML :
    ...
    ChRSM
    {
    id : chRSM
    }
    ...

    In C++ :
    CChRSM::CChRSM(QObject* ChParent /= NULL/)
    : QObject(
    ChParent)
    ....

    Thanks...


  • Qt Champions 2017

    Hi
    You mean you made a custom QML component in c++ and when used
    in QML, the c++ object created by the engine is
    not being given a parent in constructor?

    But what is the parent in QML you show ?



  • exactly, problem is as you define. I am beginner for QML. I just define the object as follows;

    ApplicationWindow
    {
    id : window
    width : 360
    height : 520
    visible : true
    title : "Quasar"

    header: ToolBar
    {
    	id					: chObject
    	Material.foreground	: "white"
    
    	RowLayout
    	{
    		spacing			: 20
    		anchors.fill	: parent
    
    		ChRSM
    		{
    			id		: chRSM
    		}
    

    .
    ...
    ....


  • Qt Champions 2017

    Hi
    Like here i guess
    http://doc.qt.io/qt-5/qtqml-tutorials-extending-qml-example.html

    Maybe parent is set after CChRSM is constructed.

    What is the problem with parent being NULL ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.