Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Show widget or label above all widget



  • I want to display a loading screen every time a user presses a button (a process that takes a few seconds runs).

    1a38095c-9d8f-42aa-836c-0247941e38be-image.png

    QSplashScreen does not help me because that is only used before opening the application and a QDialog is not useful for me because I want that by dragging the window the application will move along with the message Loading...



  • @Flanagan

    QSplashScreen does not help me because that is only used before opening the application

    Although I'm not saying it will do what you want, you can use QSplashScreen at any point in an application.

    You should look at QProgressDialog, and try to use that as it's ready-made for you. You may have to set it modal to get your drag behaviour. At least under Linux/GNOME, dragging a modal dialog drags it's parent window with it.



  • @JonB Ah, I did not know that about modal, I will try it



  • Nope, on Windows 10, i set the QProcessDIalog to WindowModal or ApplicationModal and the dialog forbids me to even touch and move the MainWindow. If I set NonModal, I can move the window but the dialog stays there floating.



  • @Flanagan
    I think you will have no choice about this under Windows then. Either you won't be able to move the back (main) window at all, or you will be able to move it but it won't take the fore dialog with it (like it does under GNOME). I don't know why you want to be able to drag the back window while something is happening and have it take the dialog with it, but if you do I would look at have the dialog modeless and write your own code so that if the main window is moved you respond by moving the dialog yourself.


  • Lifetime Qt Champion

    Hi
    As an alternative, you can also use a custom overlay widget
    https://stackoverflow.com/questions/19362455/dark-transparent-layer-over-a-qmainwindow-in-qt/19367454#19367454

    You can disable setAttribute(Qt::WA_TransparentForMouseEvents);
    and user cannot click on MainWin while its up.
    Its inside MainWin so it follows on move.
    It uses event filter to resize it self to parent automatically.

    You can alter paint event, to only darken a sub rect if you want only part of the main looking covered.



  • @mrjj I was trying to do something similar, use a QWidget above as a screen but it didn't come out on top.

    I've seen that person use raise(), which was what I needed, thanks!


  • Lifetime Qt Champion

    @Flanagan
    Hi. good to hear.
    The thing he does with the event filter is also pretty handy as the overlay then auto resize
    if user resize the main window.



  • @mrjj Yeah, im using resizeEvent() of the parent widget to resize the overlay.


Log in to reply