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. Qt send pointer to window as reference to not create another window
Forum Update on Monday, May 27th 2025

Qt send pointer to window as reference to not create another window

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtablewidgetmainwindowpointer
4 Posts 3 Posters 1.6k 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.
  • M Offline
    M Offline
    Mr Question
    wrote on 18 May 2016, 13:28 last edited by Mr Question
    #1

    Hi there,
    I got a problem with data and windows. I got one window (let's call him A)with QTableWidget component and another(let's call him B) with few QLineEdit's to get data from user. When user press button I want send the data to A window and update table with data. I got problem qDebug() in A window shows the sent data corecttly but table is not update. I heard that the problem is in the B window(where user fills QLineEdit's with data) because I make another window A instead of using the created one. I heard that I should send pointer to A window as a reference in B window constructor . Can someone show me how I can do this?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mr Question
      wrote on 18 May 2016, 14:16 last edited by
      #2

      to get pointer of window A use this. When calling window B in constructor write(this).
      Then in window B you can do what you want with this pointer to window A.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        michelson
        wrote on 18 May 2016, 14:35 last edited by
        #3

        Mayby try using Qt's signal slot system:

        //A->reciver
        //B->sender
        
        //B
        signals:
        void B::newData_ready(QString data); //you have to pass apropriate type, assuming QString since it is from QLineEdit
        slots:
        void B::on_SendButton_clicked()
        {
            emit newData_ready(userData_LineEdit->text());
        }
        
        //A
        slots:
        void A::on_newData_ready(QString data)
        {
            QTableWidgetItem *item = new QTableWidgetItem(data);
           //here add item where u want
        }
        
        connect(B, SIGNAL(newData_ready(QString)), A, SLOT(on_newData_ready(QString)));
        

        Just a scheme so it probably wont work like that but I hope you get the point.

        1 Reply Last reply
        1
        • L Offline
          L Offline
          Loc888
          wrote on 27 Feb 2018, 17:37 last edited by Loc888
          #4
          This post is deleted!
          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