zoukankan      html  css  js  c++  java
  • Qt入门1---widget、mainwindow和Dialog区别

    摘要: 看了一个月的Qt,居然没有理清Qt中

    ------------------------------------

    1.QMainWindow

    A main window provides a framework for building an application's user interface. Qt has QMainWindow and its related classes for main window management. QMainWindow has its own layout to which you can addQToolBars, QDockWidgets, a QMenuBar, and a QStatusBar. The layout has a center area that can be occupied by any kind of widget. You can see an image of the layout below.

    2.QDialog

     

    The QDialog class is the base class of dialog windows.

     

    A dialog window is a top-level window mostly used for short-term tasks and brief communications with the user. QDialogs may be modal or modeless. QDialogs can provide a return value, and they can have default buttons. QDialogs can also have a QSizeGrip in their lower-right corner, using setSizeGripEnabled().

     

    Note that QDialog (and any other widget that has type Qt::Dialog) uses the parent widget slightly differently from other classes in Qt. A dialog is always a top-level widget, but if it has a parent, its default location is centered on top of the parent's top-level widget (if it is not top-level itself). It will also share the parent's taskbar entry.

    重要的看.............

    QDialog继承自QWidget。
    那么,看一下QDialog都新增了哪些功能。如果你需要这些新增的功能,那么考虑使用QDialog。
    Qt文档中有这样一段介绍文字:
    A dialog window is a top-level window mostly used for short-term tasks and brief communications with the user. QDialogs may be modal or modeless. QDialogs can provide a return value, and they can have default buttons. 
    从这段话可以看出,QDialog通常作为一个顶层窗口出现,允许用户进行一些选择,并返回用户选择的结果(比如:在一个配置对话框里,用户操作完后是按下了“确定”、“应用”或“取消”)。然后应用程序就可以根据用户刚才的选择决定下一步做什么(比如:如果用户刚才按下了“确定”,那么就保存用户在配置对话框中进行的更改等)。

    由于QDialog通常作为顶层窗口,所以在使用诸如QStackedLayout这样的布局类时,一般上使用QWidget这样“原始”的窗体,然后把它添加到Stacked Layout中作为其中的一个Page。

    QWidget中有个方法叫SetLayout,QDialog继承了它。

     

  • 相关阅读:
    MsSql “with”用法
    linq更新数据冲突问题解决
    sql server 查询所有的数据库名称
    不能成功加入域的问题
    系统安全之关闭那些存在隐患的高危端口
    winform窗体上的所有控件都不显示
    sql server 创建主键
    关于sql server trace的警告信息
    ASP.NET配置文件Web.config
    运行报表提示错误:Retrieving the COM class factory for component with CLSID {11BD526015B6412D80DB12BB60B8FE50}
  • 原文地址:https://www.cnblogs.com/584709796-qq-com/p/4949410.html
Copyright © 2011-2022 走看看