Hello!

I started another topic yesterday, but I guess it went far into detail.
My questions comes down to this:

How can I correctly re-assign a pointer?

In my case, I have a QtDesigner-Layout, which creates a QTableView:

Qt Code:
  1. public:
  2. QTableView *tableView;
  3. ...
  4. void setupUi(QDialog *AddressBook)
  5. {
  6. tableView = new QTableView(AddressBook);
  7. ...
  8. }
To copy to clipboard, switch view to plain text mode 

In the class which uses this layout I want to pass a pointer to a pre-defined QTableView to the one created by the layout.

AddressBook-class:
Qt Code:
  1. AddressBook::AddressBook(DataManager* dmgr, QWidget *parent): QDialog(parent)
  2. {
  3. ...
  4. tableView = dmgr->customerTableView();
  5. ...
  6. }
To copy to clipboard, switch view to plain text mode 

DataManager-class

Qt Code:
  1. ...
  2. QTableView *m_customerTableView;
  3. QTableView *customerTableView();
  4. ...
  5. m_customerTableView = new QTableView;
  6. ...
  7. QTableView *DataManager::customerTableView()
  8. {
  9. return m_customerTableView;
  10. }
  11. ...
To copy to clipboard, switch view to plain text mode 

I guess to avoid memory leaks I have to delete the original tableView created by QtDesigner.

I tried the following but could get it running, since I am not so familiar with pointers yet. (coming from Java) So there could be a misunderstanding on how pointers work.

In AddressBook-class:

Qt Code:
  1. delete tableView;
  2. QTableView *tableView = dmgr->customerTableView();
To copy to clipboard, switch view to plain text mode 

I hope you can help me.

Kind regards,
HomeR