Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Closed dialog reappears

Closed dialog reappears

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 118 Views 1 Watching
  • 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.
  • W Offline
    W Offline
    w.tkm
    wrote on last edited by
    #1

    I want the file selection dialog to appear when I click on the QML button.

    I was able to press the button to display the dialog.
    However, if you close the displayed dialog and then click on the window, the dialog reappears.(I did not click the button)
    I debugged it and for some reason it says the button was pressed even though I did not click on it.
    Why does this phenomenon occur?

    QML:

    Button {
        id: comBtn
        background: buttonBackground
        Rectangle {
            id: buttonBackground
            color: "#b7b7b7"
            implicitWidth: 100
            implicitHeight: 40
            border.color: "#808080"
            border.width: 2
        }
    
        states: [
            State {
                name: "normal"
                when: !comBtn.down
                PropertyChanges {
                    target: buttonBackground
                    color: "#00000000"
                    border.color: "#808080"
                }
            },
            State {
                name: "down"
                when: comBtn.down
                PropertyChanges {
                    target: buttonBackground
                    color: "#b7b7b7"
                    border.color: "#000000"
                }
            }
        ]
    }
    
    Connections {
        target: comBtn
        function onPressed() {
            strFilePath = MyFileSelect.fnOpenDialog();
            console.log("Pressed!")
        }
    }
    

    C++:

    QString MyFileSelect::fnOpenDialog() 
    {
    	QFileDialog fileDialog(nullptr);
    	fileDialog.setFileMode(QFileDialog::Directory);
    	fileDialog.setOption(QFileDialog::ShowDirsOnly, true);
    	if ( fileDialog.exec() ) {
    		QStringList qstrFileSavePath = fileDialog.selectedFiles();
    
    	}
    		
    	if ( qstrFileSavePath.isEmpty() ) {
    		return NULL;		
    	}
    	else {
    		return qstrFileSavePath[0];
    	}
    	
    }
    
    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