My program has to QListwidgets. When I right click on the list I have a QDialog popup. When the QDialog pops up I would like to know which QListWidget has opened it. I tried using this line of code
Qt Code:
  1. qDebug()<<QDialog->parentWidget()->objectName();
To copy to clipboard, switch view to plain text mode 
but it crashed my program.

Here is some code from my .cpp file.

(this is in the main function/constructor)
Qt Code:
  1. lists = new QTabWidget;
  2. lists->setFixedWidth(200);
  3. etfList = new QListWidget;
  4. ipoList = new QListWidget;
  5. etfList->setObjectName("ETFList");
  6. etfList->setContextMenuPolicy(Qt::CustomContextMenu);
  7. ipoList->setObjectName("IPOList");
  8. ipoList->setContextMenuPolicy(Qt::CustomContextMenu);
  9. lists->addTab(etfList, "ETF List");
  10. lists->addTab(ipoList, "IPO List");
  11.  
  12.  
  13. connect(etfList, SIGNAL(customContextMenuRequested(const QPoint &)), this,SLOT(menuPopup(const QPoint &)));
  14. connect(ipoList, SIGNAL(customContextMenuRequested(const QPoint &)), this,SLOT(menuPopup(const QPoint &)));
To copy to clipboard, switch view to plain text mode 

(this is the slot)

Qt Code:
  1. void MainWindow::menuPopup(const QPoint &point){
  2.  
  3. QDialog *dia = new QDialog();
  4. qDebug()<<dia->parentWidget()->objectName(); <---crashes on this line
  5. dia->show();
  6. }
  7. }
To copy to clipboard, switch view to plain text mode 


And in my header file:


Qt Code:
  1. class MainWindow : public QMainWindow
  2. {
  3. Q_OBJECT
  4. QTabWidget *lists;
  5. QListWidget *etfList;
  6. QListWidget *ipoList;
  7.  
  8. public:
  9. explicit MainWindow(QWidget *parent = 0);
  10.  
  11. ~MainWindow();
  12.  
  13. signals:
  14.  
  15. private slots:
  16. void menuPopup(const QPoint &point);
To copy to clipboard, switch view to plain text mode