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

  • 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);

    and PageBDialog also have a Function

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

    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.

  • Hi,


    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.


  • Moderators

    @Otis.Lin Why do you call


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


  • @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.

  • @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.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.