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. read a value from a class into another class
Forum Updated to NodeBB v4.3 + New Features

read a value from a class into another class

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 221 Views 2 Watching
  • 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.
  • G Offline
    G Offline
    Gaaaab
    wrote on last edited by
    #1

    Hello everyone,
    I have a probelm with my Qt project. I want to create a very simplified version of a flight simulator.
    In this simulation, I want a menu where you can choose the plane you want to fly with. So I created a class "choix" where you can choose your plane : when you click on a specific plane, for example, x takes the value 1.
    My problem is that I want to read this value in another class...

    jsulmJ Pl45m4P 2 Replies Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      You can't just jump in to Qt. You need to comprehend the signal/slot mechanism for passing data through the framework. Start with the many example applications.

      A QListBox (or equivalent) "signal" can send the selected entry to a "slot" in another class.

      I light my way forward with the fires of all the bridges I've burned behind me.

      1 Reply Last reply
      3
      • G Gaaaab

        Hello everyone,
        I have a probelm with my Qt project. I want to create a very simplified version of a flight simulator.
        In this simulation, I want a menu where you can choose the plane you want to fly with. So I created a class "choix" where you can choose your plane : when you click on a specific plane, for example, x takes the value 1.
        My problem is that I want to read this value in another class...

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Gaaaab said in read a value from a class into another class:

        My problem is that I want to read this value in another class

        Either implement a getter method which returns the value, or use signals/slots to emit the signal with the value (see https://doc.qt.io/qt-5/signalsandslots.html).

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        4
        • G Gaaaab

          Hello everyone,
          I have a probelm with my Qt project. I want to create a very simplified version of a flight simulator.
          In this simulation, I want a menu where you can choose the plane you want to fly with. So I created a class "choix" where you can choose your plane : when you click on a specific plane, for example, x takes the value 1.
          My problem is that I want to read this value in another class...

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          @Gaaaab

          You'll need to understand C++ first (or whatever language you are using) in order to enjoy using Qt. Otherwise you spend most of the time asking for help or trying to figure out what is going on.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          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