Qt Widgets——子区域和子窗口

ui- setupUi(this);
connect(ui- actionNew,SIGNAL(triggered()),this,SLOT(creatNewWin()));//actionNew是通过设计师创建的动作
void MainWindow::creatNewWin()
mdiWin1=new QMdiSubWindow;
mdiWin1- setWindowTitle(“未定”);
ui- mdiArea- addSubWindow(mdiWin1);
mdiWin1- resize(QSize(200,200));
mdiWin1- show();
MainWindow::~MainWindow()
delete ui;
}

______________________________________________________________________________________________

QMdiArea
公有函数如下:

QMdiSubWindow * addSubWindow(QWidget * widget, Qt::WindowFlags windowFlags = 0)
void removeSubWindow(QWidget * widget)
void setActivationOrder(WindowOrder order)//设置激活顺序,默认以创建先后激活,槽函数中有调用,枚举值见1
void setBackground(const QBrush background)//设置背景,默认灰色
void setDocumentMode(bool enabled)
void setOption(AreaOption option, bool on = true)//现只有一个选项,即创建子窗口窗口不充满这个区域,默认是充满的,枚举值见2
void setViewMode(ViewMode mode)//设置视口模式,默认area中很多小窗口,也可以是有tabBar形式的,以下这些设置tab的函数,都需要先开启这个。枚举值见3
void setTabPosition(QTabWidget::TabPosition position)//设置tabBar的方位,有东西南北四方位,遵循地理的上北下南左西右东枚举值见4
void setTabShape(QTabWidget::TabShape shape)//设置tab的形状,默认长方形,也可以像谷歌浏览器那样,梯形,枚举值见5
void setTabsClosable(bool closable)//默认否,设为true时,tab上方形成一个关闭小按钮
void setTabsMovable(bool movable)//设置是否可移动,默认false,可移动时,可拖动tab在tabBar上移动,现在的浏览器大多有这样的功能
QList QMdiSubWindow * subWindowList(WindowOrder order = CreationOrder) const
QMdiSubWindow * currentSubWindow() const
WindowOrder activationOrder() const
QBrush background() const
bool documentMode() const
bool testOption(AreaOption option) const
QMdiSubWindow * activeSubWindow() const
QTabWidget::TabPosition tabPosition() const
QTabWidget::TabShape tabShape() const
bool tabsClosable() const
bool tabsMovable() const
ViewMode viewMode() const
Public Slots

void setActiveSubWindow(QMdiSubWindow * window)
void tileSubWindows()//将所有子窗口在area的可视部分排列整齐

ui- mdiArea- setViewMode(QMdiArea::TabbedView);
ui- mdiArea- setTabPosition(QTabWidget::North);
ui- mdiArea- setTabsClosable(true);
ui- mdiArea- setTabsMovable(true);
ui- mdiArea- setTabShape(QTabWidget::Triangular);
ui- mdiArea- setOption(QMdiArea::DontMaximizeSubWindowOnActivation);
connect(ui- actionNew,SIGNAL(triggered()),this,SLOT(creatNewWin()));
void MainWindow::creatNewWin()
mdiWin1=new QMdiSubWindow;
mdiWin1- setWindowTitle(“未定”);
ui- mdiArea- addSubWindow(mdiWin1);
mdiWin1- resize(QSize(200,200));
mdiWin1- show();
MainWindow::~MainWindow()
delete ui;
void MainWindow::on_pushButton_clicked()
ui- mdiArea- tileSubWindows();
}

______________________________________________________________________________________________


 QMdiSubWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0) 
 ~QMdiSubWindow() 
void setKeyboardPageStep(int step) 
void setKeyboardSingleStep(int step) 
void setOption(SubWindowOption option, bool on = true)//未试效果,求补充,枚举值见1 
void setSystemMenu(QMenu * systemMenu).se. 
void setWidget(QWidget * widget)//主要通过个函数添加它的小部件 
int keyboardPageStep() const 
int keyboardSingleStep() const 
QMdiArea * mdiArea() const 
QMenu * systemMenu() const 
QWidget * widget() const 
bool testOption(SubWindowOption option) const 
bool isShaded() const 

Public Slots


windowStateChanged(Qt::WindowStatesoldState, Qt::WindowStatesnewState)

If you enable this option, a rubber band control is used to represent the subwindow’s outline, and the user resizes this instead of the subwindow itself. As a result, the subwindow maintains its original position and size until the resize operation has been completed, at which time it will receive a singleQResizeEvent. By default, this option is disabled.

If you enable this option, a rubber band control is used to represent the subwindow’s outline, and the user moves this instead of the subwindow itself. As a result, the subwindow remains in its original position until the move operation has completed, at which time aQMoveEventis sent to the window. By default, this option is disabled.

未经允许不得转载:Villain博客 » Qt Widgets——子区域和子窗口

赞 (0) 打赏

评论 0

评论前必须登录!

登陆 注册

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏