Hi!
I have a problem with a dialog window that doesn't close when I close the MainWindow. The dialog isn't modal, because I want a window at the side of my main window that I can display state of the progam.
I've read about parents and childs and thought that a child is closed when it's parent is. So either I've got this wrong or I've failed making the dialog a child to the main window.
Heres a shortened version of the code:
This is the dialog class:
class OutlinerEditor
: public QDialog{
Q_OBJECT
public:
OutlinerEditor ( std::vector<Renderable*> *v,
std::vector<Renderable*> *s,
{
setWindowTitle ( "Outliner" );
treeModel = new TreeModel ( cmps );
outliner = new Outliner ( sels, this );
outliner->setModel ( treeModel );
outliner->connectSelection ( );
hLayout->addWidget ( outliner );
hLayout->setMargin ( 1 );
setContentsMargins ( 1, 1, 1, 1 );
// and connections and so forth...
}// OutlinerEditor(v*,v*,W*)
};// class OutlinerEditor
class OutlinerEditor : public QDialog
{
Q_OBJECT
public:
OutlinerEditor ( std::vector<Renderable*> *v,
std::vector<Renderable*> *s,
QWidget *parent ):
QDialog ( parent )
{
setWindowTitle ( "Outliner" );
treeModel = new TreeModel ( cmps );
outliner = new Outliner ( sels, this );
outliner->setModel ( treeModel );
outliner->connectSelection ( );
hLayout = new QHBoxLayout ( this );
hLayout->addWidget ( outliner );
hLayout->setMargin ( 1 );
setContentsMargins ( 1, 1, 1, 1 );
// and connections and so forth...
}// OutlinerEditor(v*,v*,W*)
};// class OutlinerEditor
To copy to clipboard, switch view to plain text mode
This is the MainWindow class:
{
Q_OBJECT
public:
MainWindow::MainWindow ( ):
{
canvasFrame = new CanvasFrame;
/* This is where I build the dialog and connects it, the last argument is the
* pointer to the parent.
*/
OutlinerEditor *outlinerEditor = new OutlinerEditor ( NULL, NULL, this );
/* This is how I show the dialog as not modal */
outlinerEditor->show ( );
}// MainWindow()
};// class MainWindow
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow::MainWindow ( ):
QMainWindow ( )
{
canvasFrame = new CanvasFrame;
/* This is where I build the dialog and connects it, the last argument is the
* pointer to the parent.
*/
OutlinerEditor *outlinerEditor = new OutlinerEditor ( NULL, NULL, this );
/* This is how I show the dialog as not modal */
outlinerEditor->show ( );
}// MainWindow()
};// class MainWindow
To copy to clipboard, switch view to plain text mode
thanks for reading
pir
Bookmarks