Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. How change a Variable from another class
Forum Update on Monday, May 27th 2025

How change a Variable from another class

Scheduled Pinned Locked Moved Unsolved Language Bindings
2 Posts 2 Posters 604 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
    Codmasters
    wrote on 19 Aug 2020, 09:52 last edited by
    #1

    Hi
    I am kind of a newbee in Qt.
    I have a Class a which has a Bool variable like
    Class A:

    bool cont = false ;
    

    now I want to change the variable to true in another class
    Class B:

    Class_a temp;
    temp.cont = true;
    

    but when I call the variable in class C it still give me "FALSE"
    Class C:

    Class_a temp;
    qDebug() << temp.cont;
    

    the code gives me "False" instead of TRUE

    K 1 Reply Last reply 19 Aug 2020, 09:59
    0
    • C Codmasters
      19 Aug 2020, 09:52

      Hi
      I am kind of a newbee in Qt.
      I have a Class a which has a Bool variable like
      Class A:

      bool cont = false ;
      

      now I want to change the variable to true in another class
      Class B:

      Class_a temp;
      temp.cont = true;
      

      but when I call the variable in class C it still give me "FALSE"
      Class C:

      Class_a temp;
      qDebug() << temp.cont;
      

      the code gives me "False" instead of TRUE

      K Offline
      K Offline
      KroMignon
      wrote on 19 Aug 2020, 09:59 last edited by
      #2

      @Codmasters said in How change a Variable from another class:

      the code gives me "False" instead of TRUE

      This has nothing to do with Qt, first try to learn C++, there are many online trainings available.

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      1 Reply Last reply
      3

      2/2

      19 Aug 2020, 09:59

      • Login

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