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 disable default button from Dialog

How to disable default button from Dialog

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 4.1k 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.
  • L Offline
    L Offline
    Lucian
    wrote on last edited by
    #1

    Hey,
    I have a simple qml file like this:

    Item {
    
        signal qmlYesSig(string msg)
        signal qmlNoSig (string msg)
        Dialog {
            id: dialog
            visible: true
            width:300
            height:300
            Button {
                text: "No"
                onClicked: qmlNoSig("NO")
                // dialog.close()
                x:0
                y:0
            }
            Button {
                text: "Yes"
                onClicked: qmlYesSig("YES")
                x:0
                y:40
            }
        }
    }
    

    By default it add an "ok" button and i don't know how to remove it.
    On the internet i have found something about this but only for controls declare in C++, not for qml.
    Is possible to dezactivate the default button?

    E 1 Reply Last reply
    0
    • L Lucian

      Hey,
      I have a simple qml file like this:

      Item {
      
          signal qmlYesSig(string msg)
          signal qmlNoSig (string msg)
          Dialog {
              id: dialog
              visible: true
              width:300
              height:300
              Button {
                  text: "No"
                  onClicked: qmlNoSig("NO")
                  // dialog.close()
                  x:0
                  y:0
              }
              Button {
                  text: "Yes"
                  onClicked: qmlYesSig("YES")
                  x:0
                  y:40
              }
          }
      }
      

      By default it add an "ok" button and i don't know how to remove it.
      On the internet i have found something about this but only for controls declare in C++, not for qml.
      Is possible to dezactivate the default button?

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @Lucian What are the import statements in your file? There are three different Dialog types in QML.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Lucian
        wrote on last edited by
        #3

        Hey @Eeli-K ,
        I'm sorry but i didn't understand your question :D

        E 1 Reply Last reply
        0
        • L Lucian

          Hey @Eeli-K ,
          I'm sorry but i didn't understand your question :D

          E Offline
          E Offline
          Eeli K
          wrote on last edited by Eeli K
          #4

          @Lucian The import statements in your qml file reveal what Dialog type you are using. If you open Index in the Qt Creator Help and look for Dialog you get three different Dialog types (in Qt 5.8). It's easier to answer to your question if we know which one of the three Dialogs you are using.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Adrian.Aioanei
            wrote on last edited by
            #5

            Right, sorry .
            Here are my imports

            import QtQuick 2.3
            import QtQuick.Window 2.0
            import QtQuick.Controls 1.2
            import QtQuick.Dialogs 1.2
            
            E 1 Reply Last reply
            0
            • A Adrian.Aioanei

              Right, sorry .
              Here are my imports

              import QtQuick 2.3
              import QtQuick.Window 2.0
              import QtQuick.Controls 1.2
              import QtQuick.Dialogs 1.2
              
              E Offline
              E Offline
              Eeli K
              wrote on last edited by
              #6

              @Adrian.Aioanei Then it's from QtQuick.Dialogs 1.2. Just look at the documentation and the property contentItem. It replaces the whole content, including the default buttons, and you can declare your own buttons. On the other hand the standardButtons property does what you want and maybe more - I don't know why you would want to declare your own "Yes" and "No" buttons and new signals while the standard ones are available.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Adrian.Aioanei
                wrote on last edited by
                #7

                Hey @Eeli-K
                My interface has a different type of button and the default button from dialog are old and ugly.
                The contentitem doesn't seem to help me, if you took about this from here Doc Qt

                E 1 Reply Last reply
                0
                • A Adrian.Aioanei

                  Hey @Eeli-K
                  My interface has a different type of button and the default button from dialog are old and ugly.
                  The contentitem doesn't seem to help me, if you took about this from here Doc Qt

                  E Offline
                  E Offline
                  Eeli K
                  wrote on last edited by
                  #8

                  @Adrian.Aioanei Why it doesn't help to remove the default buttons? "...it is possible to bind contentItem to a custom Item, in which case there will be no buttons, no margins, and the custom content will fill the whole dialog."

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Adrian.Aioanei
                    wrote on last edited by
                    #9
                    This post is deleted!
                    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