Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. 子窗体显示的时候怎么让父窗体阻塞并且子窗体可以任意移动?
Forum Updated to NodeBB v4.3 + New Features

子窗体显示的时候怎么让父窗体阻塞并且子窗体可以任意移动?

Scheduled Pinned Locked Moved Unsolved Chinese
4 Posts 3 Posters 4.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    flydragon
    wrote on last edited by
    #1

    试过setWindowFlags(Qt::FramelessWindowHint)但是效果并不是我想要的

    joeQJ 2 Replies Last reply
    0
    • F flydragon

      试过setWindowFlags(Qt::FramelessWindowHint)但是效果并不是我想要的

      joeQJ Offline
      joeQJ Offline
      joeQ
      wrote on last edited by
      #2

      @flydragon hi, friend. welcome.

      you can find some helpful information from qt help manual.

      int QDialog::exec()
      Shows the dialog as a modal dialog, blocking until the user closes it. The function returns a DialogCode result.
      If the dialog is application modal, users cannot interact with any other window in the same application until they close the dialog. If the dialog is window modal, only interaction with the parent window is blocked while the dialog is open. By default, the dialog is application modal.

      like below code snippet:

      /**.....*/
      QDialog dlg(parent);
      dlg.exec();
      /**.....*/
      

      Just do it!

      1 Reply Last reply
      0
      • F flydragon

        试过setWindowFlags(Qt::FramelessWindowHint)但是效果并不是我想要的

        joeQJ Offline
        joeQJ Offline
        joeQ
        wrote on last edited by
        #3

        @flydragon 朋友,你好,欢迎。

        我再使用中文回复一下吧, 毕竟在中文论坛里面;

        首先,窗体的显示分为两种模式,非模态和模态。 您的需求就属于模态显示。 子窗体显示在父窗体上面,阻塞父窗体的行为。

        当您查看Qt的帮助文档的时候,您就会看到以下内容:

        int QDialog::exec()
        Shows the dialog as a modal dialog, blocking until the user closes it. The function returns a DialogCode result.
        If the dialog is application modal, users cannot interact with any other window in the same application until they close the dialog. If the dialog is window modal, only interaction with the parent window is blocked while the dialog is open. By default, the dialog is application modal.

        exe()这个函数,就会使窗体进行模态的显示,使这个窗体进入Qt的事件循环。直到这个窗体关闭。它的父窗体才可以活动。

        简单的代码片段:

        /**.....*/
        QDialog dlg(parent); ///记得把父窗口的指针传递给子窗体
        dlg.exec();
        /**.....*/
        

        Just do it!

        1 Reply Last reply
        1
        • CN_SimoC Offline
          CN_SimoC Offline
          CN_Simo
          wrote on last edited by
          #4

          窗口类都有一个成员函数可以设置窗口是否模态,大概语法是setWindowModality(Qt::NonModal | Qt::Modal),
          因为默认就是模态的,所以不用自己设置。

          I am a chinese!我是一个中国人!Please,Thank you!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved