Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Signals and slots C++ too QML
Forum Updated to NodeBB v4.3 + New Features

Signals and slots C++ too QML

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 267 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.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by Circuits
    #1

    Up until now I haven't had to mess around with the C++ code on the back-end of this GUI. I have been able to avoid altering C++ code but I can't any longer. So I need to learn how it works. What I am trying to do is create a function that emit's a signal whenever it is called and I would like to call it from QML by establishing a connection, something like this:

    Connections
          {
            target: presentationManager.guiSettingsPresenter
            onWizardBoolHasChanged{//do some logic here}
          }
    

    I also need to be able to call the method from QMl, something like this:

    presentationManager.guiSettingsPresenter.wizardBool
    

    here is the function I have created to call:

    void GuiSettingsPresenter::wizardBool()
    {
        m_wizardBool == false ? m_wizardBool = true : m_wizardBool = false;
        emit wizardBoolHasChanged();
    }
    

    it's rather simple it just emit's a signal whenever the bool is flipped. Here it is instantiated in the header and I made a signal for it:

    public:
        void wizardBool();
    
    signals:
        void wizardBoolHasChanged();
    
    private:
        bool m_wizardBool = false;
    

    I believe I have done everything right so far but perhaps not. I think the next thing I need is a Q_PROPERTY? Do I even need a Q_PROPERTY I tried testing it and it doesn't seem to work.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Circuits
      wrote on last edited by
      #2

      Never mind I figured this out I guess I needed to import the manager inside of main... closing.

      1 Reply Last reply
      0

      • Login

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