• 5460阅读
  • 2回复

两个工具条,怎么让它们同时放在上面或下面,但不重叠(已解决) [复制链接]

上一主题 下一主题
离线duduqq
 

只看楼主 倒序阅读 楼主  发表于: 2008-07-02
— 本帖被 XChinux 执行加亮操作(2008-07-02) —
在一个窗本上有两个工具条,怎么让它们一开始时就放在窗体的上面或者下面,但是不要接在一起,也不能重叠在一起


PS:Qt Designer自动解决这个问题,手写代码就用insertToolBarBreak()
[ 此贴被duduqq在2008-07-03 09:22重新编辑 ]
离线XChinux

只看该作者 1楼 发表于: 2008-07-02
用Designer很容易就实现的呀?
  1. /********************************************************************************
  2. ** Form generated from reading ui file 'designerHp3936.ui'
  3. **
  4. ** Created: Wed Jul 2 23:07:47 2008
  5. **      by: Qt User Interface Compiler version 4.4.0
  6. **
  7. ** WARNING! All changes made in this file will be lost when recompiling ui file!
  8. ********************************************************************************/
  9. #ifndef DESIGNERHP3936_H
  10. #define DESIGNERHP3936_H
  11. #include <QtCore/QVariant>
  12. #include <QtGui/QAction>
  13. #include <QtGui/QApplication>
  14. #include <QtGui/QButtonGroup>
  15. #include <QtGui/QMainWindow>
  16. #include <QtGui/QMenuBar>
  17. #include <QtGui/QStatusBar>
  18. #include <QtGui/QToolBar>
  19. #include <QtGui/QWidget>
  20. QT_BEGIN_NAMESPACE
  21. class Ui_MainWindow
  22. {
  23. public:
  24.     QAction *actionEeee;
  25.     QWidget *centralwidget;
  26.     QMenuBar *menubar;
  27.     QStatusBar *statusbar;
  28.     QToolBar *toolBar;
  29.     QToolBar *toolBar_2;
  30.     void setupUi(QMainWindow *MainWindow)
  31.     {
  32.     if (MainWindow->objectName().isEmpty())
  33.         MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
  34.     MainWindow->resize(549, 524);
  35.     actionEeee = new QAction(MainWindow);
  36.     actionEeee->setObjectName(QString::fromUtf8("actionEeee"));
  37.     centralwidget = new QWidget(MainWindow);
  38.     centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
  39.     centralwidget->setGeometry(QRect(0, 64, 549, 442));
  40.     MainWindow->setCentralWidget(centralwidget);
  41.     menubar = new QMenuBar(MainWindow);
  42.     menubar->setObjectName(QString::fromUtf8("menubar"));
  43.     menubar->setGeometry(QRect(0, 0, 549, 18));
  44.     MainWindow->setMenuBar(menubar);
  45.     statusbar = new QStatusBar(MainWindow);
  46.     statusbar->setObjectName(QString::fromUtf8("statusbar"));
  47.     statusbar->setGeometry(QRect(0, 506, 549, 18));
  48.     MainWindow->setStatusBar(statusbar);
  49.     toolBar = new QToolBar(MainWindow);
  50.     toolBar->setObjectName(QString::fromUtf8("toolBar"));
  51.     toolBar->setGeometry(QRect(0, 18, 549, 23));
  52.     MainWindow->addToolBar(Qt::TopToolBarArea, toolBar);
  53.     toolBar_2 = new QToolBar(MainWindow);
  54.     toolBar_2->setObjectName(QString::fromUtf8("toolBar_2"));
  55.     toolBar_2->setGeometry(QRect(0, 41, 549, 23));
  56.     MainWindow->addToolBar(Qt::TopToolBarArea, toolBar_2);
  57.     MainWindow->insertToolBarBreak(toolBar_2);
  58.     toolBar->addAction(actionEeee);
  59.     toolBar_2->addAction(actionEeee);
  60.     retranslateUi(MainWindow);
  61.     QMetaObject::connectSlotsByName(MainWindow);
  62.     } // setupUi
  63.     void retranslateUi(QMainWindow *MainWindow)
  64.     {
  65.     MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
  66.     actionEeee->setText(QApplication::translate("MainWindow", "eeee", 0, QApplication::UnicodeUTF8));
  67.     toolBar->setWindowTitle(QApplication::translate("MainWindow", "toolBar", 0, QApplication::UnicodeUTF8));
  68.     toolBar_2->setWindowTitle(QApplication::translate("MainWindow", "toolBar_2", 0, QApplication::UnicodeUTF8));
  69.     } // retranslateUi
  70. };
  71. namespace Ui {
  72.     class MainWindow: public Ui_MainWindow {};
  73. } // namespace Ui
  74. QT_END_NAMESPACE
  75. #endif // DESIGNERHP3936_H
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线duduqq

只看该作者 2楼 发表于: 2008-07-03
非常感谢,总版主不错
insertToolBarBreak()解决了
快速回复
限100 字节
 
上一个 下一个