qt form in full screen

Original Address: https://www.cnblogs.com/wiessharling/p/3750461.html

Recently encountered a lot of problems in learning QT This is also one of the individuals through a variety of books available on the Internet and find some answers in this regard, we hope to give you some help.

First, in the QT commonly used for window displays there are so few ways you can call:


Qt showFullScreen full screen function ()
Qt Extents showMaximized function ()
Qt minimized display function showMinimized ()
Qt fixed size of the display function a resize (X, Y)
Qt maximum size setting function setMaximumSize (W, H)
Qt minimum size setting function setMinimumSize (w, h)

but showFullScreen () only to top-level window effect, invalid sub-window;
setWindowFlags (Qt :: window | Qt :: FramelessWindowHint); The first parameter indicates whether this control window type, the second one is the removal of borders, the status bar, no framework. In fact, with showFullScreen () function works almost.


To Second sub-window full screen display using the following method:
        a sub-window to full screen Qt main window function calls setWindowFlags (Qt :: Dialog), or by calling setWindowFlags (Qt :: Window) to enhance the top-level window type mode, and then call showFullScreen () function sub-window full screen. That is, before the first sub-window full-screen display is set to top-level window and full-screen display, note the order can not be reversed. Because showFullScreen () function is valid only for top-level window.
        Of course, recovery to normal full screen, i.e., calls setWindowFlags (Qt :: subwindow), or setWindowFlags (Qt :: Dialog), the sub-window non-top-level window is provided, then call showNormal () further window atoms. Direct call mywindow.resize (x, y) is not effective. Note that the function calling sequence can not be reversed, not those who are not restored. The reason is simple, because showNormal () only valid for top-level window. So it must be recalled as a non-top-level window.
        If you need to know the screen aspect can call the following functions:
          QApplication :: Desktop () -> height ();
        QApplication :: Desktop () -> width ();
for example:
       full screen display:
       VideoWidget-> setWindowFlags (Qt :: Window);
       VideoWidget-> showFullScreen ();
       when exiting full screen:
    VideoWidget-> setWindowFlags (Qt :: subwindow);
       VideoWidget-> showNormal ();
      when you have to exit full-screen, right-click pop-up menu screen is obtained, it can be captured get keyboard events such as:
      keyPressEvent (QKeyEvent * keySet)
     {
      IF (keyset-> Key () == Qt :: Key_Escape) {
           VideoWidget->setWindowFlags (Qt::SubWindow);
           VideoWidget->showNormal ();
     }

}

Guess you like

Origin www.cnblogs.com/xiangtingshen/p/12052482.html