JObs with QMdiSubWindow!



  • Create 3 window. Why when i close ssb3, close ss2? How released?
    @
    #include "naklwindow.h"

    NaklWindow::NaklWindow()
    {
    setupUi(this);

    mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation,true);
    
    db = QSqlDatabase::addDatabase("QIBASE");
    db.setHostName("localhost");
    db.setDatabaseName("D:\\Data\\data.fdb");
    db.setUserName("sysdba");
    db.setPassword("masterkey");
    db.open();
    
    model = new QSqlRelationalTableModel();
    model->setTable("trustdoc");
    
    model->setRelation(3,QSqlRelation("contragent","id","name"));
    model->setRelation(4,QSqlRelation("datacompany", "id", "name"));
    model->setRelation(5,QSqlRelation("sppeople", "id", "fio"));
    
    model->setHeaderData(0, Qt::Horizontal, trUtf8("№"));
    model->setHeaderData(1, Qt::Horizontal, trUtf8("Дата выдачи"));
    model->setHeaderData(3, Qt::Horizontal, trUtf8("Поставщик"));
    model->setHeaderData(5, Qt::Horizontal, trUtf8("Выдана"));
    
    model->select();
    
    tableView->setModel(model);
    
    tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    tableView->setItemDelegate(new QSqlRelationalDelegate(tableView));
    tableView->setColumnHidden(2,true);
    tableView->setColumnHidden(4,true);
    tableView->setColumnHidden(6,true);
    tableView->setColumnHidden(7,true);
    
    QMdiSubWindow *ssb= mdiArea->addSubWindow(tableView);
    ssb->setWindowFlags(Qt::FramelessWindowHint);
    ssb->showMaximized();
    
    createAction();
    createToolBar();
    setCentralWidget(mdiArea);
    

    }

    void NaklWindow::createAction()
    {
    add = new QAction(QIcon(":/images/note_add.png"),trUtf8("Добавить"),this);
    connect(add,SIGNAL(triggered()),SLOT(addShow()));

    edit = new QAction(QIcon(":/images/note_edit.png"),trUtf8("Изменить"),this);
    connect(edit,SIGNAL(triggered()),SLOT(editShow()));
    
    del = new QAction(QIcon(":/images/note_del.png"),trUtf8("Удалить"),this);
    connect(del,SIGNAL(triggered()),SLOT(delShow()));
    
    find = new QAction(QIcon(":/images/note_find.png"),trUtf8("Поиск"),this);
    

    }

    void NaklWindow::createToolBar()
    {
    toolBar->addAction(add);
    toolBar->addAction(edit);
    toolBar->addAction(del);
    toolBar->addAction(find);
    }

    void NaklWindow::addShow()
    {

    nkaddWindow = new NaklAddWindow;
    QMdiSubWindow *ssb2 = mdiArea->addSubWindow(nkaddWindow);
    connect(nkaddWindow->getButtonPol(),SIGNAL(clicked()),SLOT(addPolychatelShow()));
    ssb2->show();
    

    }

    void NaklWindow::editShow()
    {

    }

    void NaklWindow::delShow()
    {

    }

    void NaklWindow::addPolychatelShow()
    {

    QTableView *table = new QTableView;
    QMdiSubWindow *ssb3=mdiArea->addSubWindow(table);
    ssb3->show();
    

    }

    @



  • I see problem on line 78. Where is 3rd agrument: Receiver?



  • The receiver is "this". It's an overload of "QObject::connect()":http://doc.qt.nokia.com/4.7/qobject.html#connect-2



  • I don't understand very well your problem... Can you describe it better?



  • [quote author="Luca" date="1289586569"]I don't understand very well your problem... Can you describe it better?
    [/quote]

    I create three windows. Creates at once a window №1, after pressing in the first window of the button - the window №2 is created, after button pressing in a window №2 - the window №3 is created. When I close a window №3 the window №2 is closed also. But if I close a window №2 window №3 together it is not closed. It would be necessary to me that when I close a window №3 window №2 wasn't closed together. Help!



  • Can you post the full source code (in a .zip or .tar.*) so people can test themselves?



  • "Full source code":http://www27.zippyshare.com/v/80867820/file.html
    Press Журналы -> Накладные, then + , field Получатель button [...], and close last window.



  • You have at least two MDI areas that are nested - one should be enough for a single application. Also, you set QMainWindows into the QMdiSubWindows, which seems not to be a good idea. It also does not make any sense, as you only have one main window with an MDI application.

    I'd suggest cleaning up these issues before going any further.



  • ок!



  • can u give me advice or maybe show an example



  • There is an "MDI Example":http://doc.qt.nokia.com/4.7/mainwindows-mdi.html in the Qt docs.

    You should have an MDI area in your "main" MainWindow. If you need to instantiate sub windows from another subwindow you should do this via methods in the main window class. At least it is strange to have another MDI area an an MDI subwindow.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.