mdi例子中
void ApplicationWindow::tileHorizontal()
{
// primitive horizontal tiling
QWidgetList windows = ws->windowList();
if ( !windows.count() )
return;
int heightForEach = ws->height() / windows.count();
int y = 0;
for ( int i = 0; i < int(windows.count()); ++i ) {
QWidget *window = windows.at(i);
if ( window->testWState( WState_Maximized ) ) {
// prevent flicker
window->hide();
window->showNormal();
}
int preferredHeight = window->minimumHeight()+window->parentWidget()->baseSize().height();
int actHeight = QMAX(heightForEach, preferredHeight);
window
->parentWidget()->setGeometry( 0, y, ws->width(), actHeight );//
y += actHeight;
}
}
-----------------------------------------------------------------------------------------------
为什么要用parentWidget(),为什么不直接用window->setGeometry( 0, y, ws->width(), actHeight );
[ 此贴被snow_man_0在2008-03-26 11:03重新编辑 ]