Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    JObs with QMdiSubWindow!

    General and Desktop
    5
    11
    4683
    Loading More Posts
    • 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
      mbynet last edited by

      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();
      

      }

      @

      1 Reply Last reply Reply Quote 0
      • I
        iunknwn last edited by

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

        Vista x64 with Qt 4.8.2 and VS2010

        1 Reply Last reply Reply Quote 0
        • G
          goetz last edited by

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

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply Reply Quote 0
          • L
            luca last edited by

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

            1 Reply Last reply Reply Quote 0
            • M
              mbynet last edited by

              [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!

              1 Reply Last reply Reply Quote 0
              • F
                Franzk last edited by

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

                "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply Reply Quote 0
                • M
                  mbynet last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • G
                    goetz last edited by

                    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.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply Reply Quote 0
                    • M
                      mbynet last edited by

                      ок!

                      1 Reply Last reply Reply Quote 0
                      • M
                        mbynet last edited by

                        can u give me advice or maybe show an example

                        1 Reply Last reply Reply Quote 0
                        • G
                          goetz last edited by

                          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.

                          http://www.catb.org/~esr/faqs/smart-questions.html

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post