Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to set a dialog ontop on the page,and except for other programs
Qt 6.11 is out! See what's new in the release blog

How to set a dialog ontop on the page,and except for other programs

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 2.9k 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.
  • O Offline
    O Offline
    Otis.Lin
    wrote on last edited by
    #1

    hi everyone I use Qt5.5 on MacOS
    the problem is
    I have a main pageA, and have a button, when I push button
    it will exec() pageB, and pageB also have a button, the button will show a dialog is pageC.
    But I want pageC always top on the pageB, but if I open other app pageC can't on the top.

    the Main pageA is a QMainWindow and have a function

    void ButtonClickExecPageB ()  
    {
        QDialog *PageB = new PageBDialog(this);
        PageB->setWindowFlags(Qt::Window|Qt::WindowCloseButtonHint);
        PageB->exec();
    }
    

    and PageBDialog also have a Function

    void ButtonClickShowPageC()
    {
    QDialog *PageC = new PageCDialog(this);
    PageC->setWindowFlags(Qt::Dialog | Qt::WindowStaysOnTopHint);
    PageC->show();
    }
    

    I set WindowStaysOnTopHint for PageC, but if I Click PageB the PageC will goto bottom, if I open other app it on the Top its very strange.

    I also try PageC->setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint), now I open other app it will go to bottom.
    But if I Click PageB the PageC still goto bottom.
    somebody have any idea? please teach me please.
    thanks.

    jsulmJ 1 Reply Last reply
    0
    • Pradeep KumarP Offline
      Pradeep KumarP Offline
      Pradeep Kumar
      wrote on last edited by
      #2

      Hi,

      @Otis-Lin

      As u said u want the respective dialogs to be on top when button is clicked, from respective screens,
      and what app ur mentioning, ru using only one app?, how is it.
      coz u said if if ur using other app, pageC cant be on top. from ur post,

      And looking at the slot, each time when u click button memory is created for respective Dialogs, and leading to memory leak, each time dialog object gets created, be caution.
      in case ur deleting its k.

      Thanks,

      Pradeep Kumar
      Qt,QML Developer

      O 1 Reply Last reply
      0
      • O Otis.Lin

        hi everyone I use Qt5.5 on MacOS
        the problem is
        I have a main pageA, and have a button, when I push button
        it will exec() pageB, and pageB also have a button, the button will show a dialog is pageC.
        But I want pageC always top on the pageB, but if I open other app pageC can't on the top.

        the Main pageA is a QMainWindow and have a function

        void ButtonClickExecPageB ()  
        {
            QDialog *PageB = new PageBDialog(this);
            PageB->setWindowFlags(Qt::Window|Qt::WindowCloseButtonHint);
            PageB->exec();
        }
        

        and PageBDialog also have a Function

        void ButtonClickShowPageC()
        {
        QDialog *PageC = new PageCDialog(this);
        PageC->setWindowFlags(Qt::Dialog | Qt::WindowStaysOnTopHint);
        PageC->show();
        }
        

        I set WindowStaysOnTopHint for PageC, but if I Click PageB the PageC will goto bottom, if I open other app it on the Top its very strange.

        I also try PageC->setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint), now I open other app it will go to bottom.
        But if I Click PageB the PageC still goto bottom.
        somebody have any idea? please teach me please.
        thanks.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Otis.Lin Why do you call

        PageC->show();
        

        if you want PageC to be always on top of PageB?
        Use

        PageC->exec();
        

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        O 1 Reply Last reply
        2
        • Pradeep KumarP Pradeep Kumar

          Hi,

          @Otis-Lin

          As u said u want the respective dialogs to be on top when button is clicked, from respective screens,
          and what app ur mentioning, ru using only one app?, how is it.
          coz u said if if ur using other app, pageC cant be on top. from ur post,

          And looking at the slot, each time when u click button memory is created for respective Dialogs, and leading to memory leak, each time dialog object gets created, be caution.
          in case ur deleting its k.

          Thanks,

          O Offline
          O Offline
          Otis.Lin
          wrote on last edited by Otis.Lin
          #4

          @Pradeep-Kumar
          it's like I click button and show the PageC, now maybe I open the safari, in normally safari
          will up than PageC, but in fact only PageC will up than safari.
          The program just a example so it's not very rigorous, thanks for your reminder.

          1 Reply Last reply
          0
          • jsulmJ jsulm

            @Otis.Lin Why do you call

            PageC->show();
            

            if you want PageC to be always on top of PageB?
            Use

            PageC->exec();
            
            O Offline
            O Offline
            Otis.Lin
            wrote on last edited by
            #5

            @jsulm
            hello, because if show PageB I don't want user can use PageA so I use PageB-> exec().
            But the PageC it's like a sub function. the PageC will always on the PageB, and I can use the PageB and PageC.

            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