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. Using Loader Objects to Access C++ Methods

Using Loader Objects to Access C++ Methods

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.1k 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.
  • T Offline
    T Offline
    Tjsail33
    wrote on 3 Mar 2012, 19:56 last edited by
    #1

    Is it possible to have QML files I load into a Loader object access C++ methods that the parent of the Loader has access to?

    @
    //Gives access to the main qml file
    this->ui->declarativeView->rootContext()->setContextProperty("appDelegate",this);
    @

    @
    //The Loader View that I would like to be able to use this method
    //Loader is a child of a Rectangle, which is the root object
    Loader {
    source: "MainNode.qml"
    anchors.centerIn: parent
    }
    @

    @
    //What I would like to do with the method in MainNode.qml
    //MouseArea is a child of a Rectangle, which is the root of the file.
    MouseArea {
    anchors.fill: parent
    onDoubleClicked: {
    parent.width: appDelegate.getScreenWidth();
    }
    }
    @

    How would I go about implementing this interaction?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 3 Mar 2012, 23:06 last edited by
      #2

      Is it not working when you just run what you wrote here?

      (Z(:^

      1 Reply Last reply
      0

      1/2

      3 Mar 2012, 19:56

      • Login

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