[英]How do I know which button is clicked in the popup window when using QFileDialog.getSaveFileName
如果未選擇文件,即按下取消按鈕時, QFileDialog::getSaveFileName()
方法返回一個空字符串,而當按下保存按鈕時返回一個非空字符串:
filename, _ = QFileDialog.getSaveFileName()
if filename:
print("The save button is pressed")
else:
print("The cancel button is pressed")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.