Results 1 to 4 of 4

Thread: Debug says vaiable is empty but it isn't

  1. #1
    Join Date
    Apr 2020
    Posts
    14
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Debug says vaiable is empty but it isn't

    Hallo,

    my program is split into several cpp and h files.

    The GUI window is in dialog.cpp and dialog.h

    The scan is in scan.cpp and scan. h

    Save is in file.cpp and file.h

    Scan is storing the results in a public QVector. When i hit a button in GUI i can see the output of QVector in the debug. When I hit save, nothing from the QVector is saved. Debugger shows QVector empty.

    dialog.h
    Qt Code:
    1. private:
    2. Ui::Dialog *ui;
    3. FM_rds mRds;
    4. Scan mScan;
    5. Tune mTune;
    6. Mute mMute;
    7. File mFile;
    To copy to clipboard, switch view to plain text mode 

    dialog.cpp (show content of QVector in Debug and save button)
    Qt Code:
    1. void Dialog::on_pushButton_clicked()
    2. {
    3. qDebug() << "dab_vev_vec: " << mScan.dab_vec_vec;
    4. }
    5.  
    6. void Dialog::on_pushButton_2_clicked()
    7. {
    8. mFile.dab_write_file();
    9. }
    To copy to clipboard, switch view to plain text mode 

    file.h
    Qt Code:
    1. #include <scan.h>
    2.  
    3. private:
    4.  
    5. Scan mScan;
    To copy to clipboard, switch view to plain text mode 

    file.cpp
    Qt Code:
    1. for(int i = 0; i < mScan.dab_vec_vec.size(); i++){
    2.  
    3. dab_vec_vec_to_line = mScan.dab_vec_vec[i][0] + "," + mScan.dab_vec_vec[i][1] + "," + mScan.dab_vec_vec[i][2] + "," + mScan.dab_vec_vec[i][3];
    4. qDebug() << "i: " << i << "dabvecvectoline: " << dab_vec_vec_to_line;
    5. unsort_list.append(dab_vec_vec_to_line);
    6. }
    To copy to clipboard, switch view to plain text mode 

    scan.h
    Qt Code:
    1. public:
    2.  
    3. QVector<QVector<QString>> dab_vec_vec;
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Debug says vaiable is empty but it isn't

    mScan in dialog,h and file.h is not the same object.

  3. #3
    Join Date
    Apr 2020
    Posts
    14
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Debug says vaiable is empty but it isn't

    Ok, how can I access the variable for File else? I wanted to avoid using a global variable.
    Last edited by vitalic; 15th May 2020 at 18:03.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Debug says vaiable is empty but it isn't

    Keep mScan in one class (your File class, for example). Add a setScans() method to your Dialog class to copy this data into the Dialog class instance before your call to exec(). Or keep it in your Dialog class and pass it as an argument to File:: dab_write_file().
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. QT C++ Empty Console when compiling in Debug mode
    By Kuma in forum Installation and Deployment
    Replies: 0
    Last Post: 21st April 2016, 23:51
  2. Qt + Linux + Eclipse - debug using debug build?
    By will49 in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2012, 07:27
  3. Replies: 4
    Last Post: 30th September 2010, 11:31
  4. remove directory empty or not empty
    By raphaelf in forum Newbie
    Replies: 12
    Last Post: 27th October 2006, 08:30
  5. Replies: 11
    Last Post: 22nd March 2006, 20:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.