博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

Creatory

Y(^_^)Y I hope someday we can meet on the road =^_^=
   creatory.cublog.cn
关于作者  
姓名:creatory
职业:Embedded-Linux
年龄:22
格言:努力就有可能成功
院校:SDUST
联系我:creatory@mail.com
creatory@163.com

我的分类  




The Key Code of Multiple Document Interface
//create new child window and add up to QWorkspace then return a pointer
MdiChild *MainWindow::createMdiChild()
    {
        MdiChild *child = new MdiChild;
        workspace->addWindow(child);

        connect(child, SIGNAL(copyAvailable(bool)),
                cutAct, SLOT(setEnabled(bool)));
        connect(child, SIGNAL(copyAvailable(bool)),
                copyAct, SLOT(setEnabled(bool)));

        return child;
    }

//Get the current active window
MdiChild *MainWindow::activeMdiChild()
    {
        return qobject_cast<MdiChild *>(workspace->activeWindow());
    }
//Find the specify window
MdiChild *MainWindow::findMdiChild(const QString &fileName)
    {
        QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath();

        foreach (QWidget *window, workspace->windowList()) {
            MdiChild *mdiChild = qobject_cast<MdiChild *>(window);
            if (mdiChild->currentFile() == canonicalFilePath)
                return mdiChild;
        }
        return 0;
    }

//update window menu
QList<QWidget *> windows = workspace->windowList();
        separatorAct->setVisible(!windows.isEmpty());

        for (int i = 0; i < windows.size(); ++i) {
            MdiChild *child = qobject_cast<MdiChild *>(windows.at(i));

            QString text;
            if (i < 9) {
                text = tr("&%1. %2").arg(i + 1)
                                    .arg(child->userFriendlyCurrentFile());
            } else {
                text = tr("%1. %2").arg(i + 1)
                                   .arg(child->userFriendlyCurrentFile());
            }
QAction *action  = windowMenu->addAction(text);
            action->setCheckable(true);
            action ->setChecked(child == activeMdiChild());
            connect(action, SIGNAL(triggered()), windowMapper, SLOT(map()));
            windowMapper->setMapping(action, child);
        }

 发表于: 2008-05-07,修改于: 2008-05-07 20:25 已浏览37次,有评论0条 推荐 投诉

  网友评论

  发表评论



Copyright © 2001-2006 ChinaUnix.net All Rights Reserved

感谢所有关心和支持过ChinaUnix的朋友们
页面生成时间:0.00909

京ICP证041476号