Qt 窗口设置

===========设置默认大小================================================================================

void QWidget::setWindowState ( Qt::WindowStates windowState )


The states are

Constant Value Description
Qt::WindowNoState 0x00000000 The window has no state set (in normal state).
Qt::WindowMinimized 0x00000001 The window is minimized (i.e. iconified).
Qt::WindowMaximized 0x00000002 The window is maximized with a frame around it.
Qt::WindowFullScreen 0x00000004 The window fills the entire screen without any frame around it.
Qt::WindowActive 0x00000008 The window is the active window, i.e. it has keyboard focus.

===========设置固定大小================================================================================

void QWidget::setFixedSize ( int w, int h )


===========设置最大化最小化边框策略=====================================================================
void QWidget::setWindowFlags ( Qt::WindowFlags type )


Qt::FrameWindowHint:没有边框的窗口
Qt::WindowStaysOnTopHint://总在最上面的窗口
Qt::CustomizeWindowHint://自定义窗口标题栏,以下标志必须与这个标志一起使用才有效,否则窗口将有默认的标题栏
Qt::WindowTitleHint:显示窗口标题栏
Qt::WindowSystemMenuHint://显示系统菜单
Qt::WindowMinimizeButtonHint://显示最小化按钮
Qt::WindowMaximizeButtonHint://显示最大化按钮
Qt::WindowMinMaxButtonsHint://显示最小化按钮和最大化按钮
Qt::WindowCloseButtonHint://显示关闭按钮
setWindowFlags(Qt::FramelessWindowHint);直接隐藏掉。。。


===========设置窗口位置至屏幕中央=======================================================================

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();// 注意:一定要先 show 再 move,否则 move 无效

    w.move ((QApplication::desktop()->width() - w.width())/2,
            (QApplication::desktop()->height() - w.height())/2);

    return a.exec();
}

=======================================================================================================

你可能感兴趣的:(qt-gui)