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 make the prompt message appear on the top of all windows in qml
Forum Update on Monday, May 27th 2025

How to make the prompt message appear on the top of all windows in qml

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 225 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.
  • J Offline
    J Offline
    johndummy
    wrote on last edited by johndummy
    #1

    I have a function which shows prompt messages to user. I want this pop up window to appear on the top of all windows and it shouldn't goes to background after clicking other windows. It should be close explicitly by the user.

    I have defined a function in qml to show the pop up window:-

        function openPrompt(promptTitle, message){
            // Prompt the user with a dialog
            var component = Qt.createComponent("showPrompt.qml");
            if (component.status === Component.Ready) {
                var dialog = component.createObject(parent);
                dialog.message = message
                dialog.promptTitle = promptTitle
               // dialog.open()
                dialog.show()
            } else {
                console.error("Error loading component:", component.errorString())
            }
        }
    

    My showPrompt.qml is as follows:-

    ApplicationWindow {
        id: window
        width: 400
        height: 30
        visible: true
        title: promptTitle
        property string message: ""
        property string promptTitle: ""
    
        Component.onCompleted: {
            // Open the Popup when the window is loaded
            popup.open()
        }
    
        Popup {
            id: popup
            width: parent.width
            height: parent.height
            modal: true
            focus: true
            closePolicy: Popup.NoAutoClose
            Text {
                text: message
                anchors.fill: parent
            }
        }
    }
    

    P.S: i'm on windows 10

    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