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. communicate data between two windows
Forum Updated to NodeBB v4.3 + New Features

communicate data between two windows

Scheduled Pinned Locked Moved Solved General and Desktop
19 Posts 6 Posters 1.9k Views 3 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.
  • AlbatorA Offline
    AlbatorA Offline
    Albator
    wrote on last edited by
    #9
    This post is deleted!
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #10

      Hi
      Should work as you put value in the vector, in the constructor.

      what does test->get_vector();
      do ?

      maybe you return empty list there ?

      1 Reply Last reply
      0
      • AlbatorA Offline
        AlbatorA Offline
        Albator
        wrote on last edited by
        #11

        @Albator said in communicate data between two windows:

        QVector<double> get_vector() const{return fer;}

        and fer is not empty, it works for c ...

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          Q139
          wrote on last edited by
          #12

          Is it wrong to use global window pointers and access setters getters via pointer instead of signals&slots?

          1 Reply Last reply
          0
          • AlbatorA Offline
            AlbatorA Offline
            Albator
            wrote on last edited by
            #13

            i want use getter in first but if i have not the choice maybe i will change my solution, it works for c so it should work for the qvector

            mrjjM 1 Reply Last reply
            0
            • AlbatorA Albator

              i want use getter in first but if i have not the choice maybe i will change my solution, it works for c so it should work for the qvector

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #14

              @Albator
              yes must also work for Qvector same way as int.

              AlbatorA 1 Reply Last reply
              0
              • mrjjM mrjj

                @Albator
                yes must also work for Qvector same way as int.

                AlbatorA Offline
                AlbatorA Offline
                Albator
                wrote on last edited by
                #15

                @mrjj
                that's what I think, but who knows where the pangolin is that's standing in the way of my code?

                mrjjM 1 Reply Last reply
                0
                • AlbatorA Albator

                  @mrjj
                  that's what I think, but who knows where the pangolin is that's standing in the way of my code?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #16

                  @Albator
                  so while it returns empty list and the same time in same code and
                  in same run, it can return 3 for c ?
                  it seems impossible :)

                  AlbatorA 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    @Albator
                    so while it returns empty list and the same time in same code and
                    in same run, it can return 3 for c ?
                    it seems impossible :)

                    AlbatorA Offline
                    AlbatorA Offline
                    Albator
                    wrote on last edited by
                    #17

                    @mrjj
                    in first i put my value :

                    seconde_p2::seconde_p2(QWidget *parent) :
                        QMainWindow(parent),
                        ui(new Ui::seconde_p2)
                    {
                        ui->setupUi(this);
                    
                        c=3;
                        fer={ 1, 2, 3, 4, 5, 6, 7 };
                        qDebug() << fer;
                    
                    
                    }
                    

                    and in second i have a button who call the other windows :

                    void seconde_p2::on_page3_clicked()
                    {
                        p3 = new seconde_p3(this);
                        p3->show();
                    }
                    

                    and for the final in the second_p3.cpp (my other window), i use my getter and display :

                    seconde_p3::seconde_p3(QWidget *parent) :
                        QMainWindow(parent),
                        ui(new Ui::seconde_p3)
                    {
                        ui->setupUi(this);
                    
                    seconde_p2* test = new seconde_p2();
                    seconde_p2* test1 = new seconde_p2();
                    
                    test->get_data1();
                    qDebug()<<"qvector<double> display"<< test->get_data1();
                    
                    test1->get_c();
                    qDebug()<<"int display"<< test1->get_c();
                    
                    
                    }
                    

                    and tadaaaa : c is displayed correctly and fer is empty
                    my conclusion ? it's a sad day :(

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Online
                      Christian EhrlicherC Online
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #18

                      @Albator said in communicate data between two windows:

                      seconde_p2* test = new seconde_p2();
                      seconde_p2* test1 = new seconde_p2();

                      C++ basics - this are new local instances - it won't help at all. You have to pass the pointer from the other object to this class. This is basic c++ stuff - programming with Qt without this basic knowledge will not work.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      AlbatorA 1 Reply Last reply
                      3
                      • Christian EhrlicherC Christian Ehrlicher

                        @Albator said in communicate data between two windows:

                        seconde_p2* test = new seconde_p2();
                        seconde_p2* test1 = new seconde_p2();

                        C++ basics - this are new local instances - it won't help at all. You have to pass the pointer from the other object to this class. This is basic c++ stuff - programming with Qt without this basic knowledge will not work.

                        AlbatorA Offline
                        AlbatorA Offline
                        Albator
                        wrote on last edited by
                        #19

                        @Christian-Ehrlicher
                        excuse me I try and thanks to your advices I advance and yes sometimes I miss my bases :)

                        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