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 reach variable from another page in Qt C++?

How to reach variable from another page in Qt C++?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 326 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.
  • mangekoyuM Offline
    mangekoyuM Offline
    mangekoyu
    wrote on last edited by
    #1

    have 2 function in different c++ files. I need reach one variable from another cpp file. How Can I do this?

    I need reach excelBuffer located on parser.cpp on inside void MainWindow::exportexcel() function located on mainwindow.cpp

    parser.cpp

    void Parser::parse(QString inputString)
    {
          
    QStringList excelBuffer =inputString.split(",");
    
       
    }
    

    mainwindow.cpp

    void MainWindow::exportexcel() {
      
         //I need reach excelbuffer from here     
        }
    
    jsulmJ 1 Reply Last reply
    0
    • O Offline
      O Offline
      odelaune
      wrote on last edited by
      #2

      Usually, we use getters/setters to do this.

      1 Reply Last reply
      3
      • mangekoyuM mangekoyu

        have 2 function in different c++ files. I need reach one variable from another cpp file. How Can I do this?

        I need reach excelBuffer located on parser.cpp on inside void MainWindow::exportexcel() function located on mainwindow.cpp

        parser.cpp

        void Parser::parse(QString inputString)
        {
              
        QStringList excelBuffer =inputString.split(",");
        
           
        }
        

        mainwindow.cpp

        void MainWindow::exportexcel() {
          
             //I need reach excelbuffer from here     
            }
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @mangekoyu said in How to reach variable from another page in Qt C++?:

        I need reach excelBuffer located on parser.cpp

        You will need to make excelBuffer class member instead of local variable and then follow what @odelaune suggested.

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

        1 Reply Last reply
        2

        • Login

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