Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to remove setContextProperty from QMLContext?
Qt 6.11 is out! See what's new in the release blog

how to remove setContextProperty from QMLContext?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 356 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RAJEESHR
    wrote on last edited by RAJEESHR
    #1

    /// in my C++ code

    MyCustomObjct* myCustomObjct = new MyCustomObjct();
    engine.rootContext()->setContextProperty("customProperty", myCustomObjct);

    How can I remove this context property once it is done with usage ?
    is there any API to reset it? or we need to call setContextProperty("customProperty, nullptr) ?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @RAJEESHR said in how to remove setContextProperty from QMLContext?:

      is there any API to reset it?

      yes

      or we need to call setContextProperty("customProperty, nullptr) ?

      correct, don't forget the object to avoid a memory leak

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved