启动PYQT QFileDialog时,用于选择当前目录的QComboBox并非所有场景中的理想小部件。我有兴趣用QLineEdit替换QComboBox,同时保持其他一切。
有什么建议吗?
答案 0 :(得分:0)
您应该从QFileDialog创建一个继承的类,并根据需要进行修改。以下是文档QFileDialog
答案 1 :(得分:-2)
要显示用户打开文件的对话框:
//Details in asterisk to hide.
<?php
define('DB_SERVER', '******');
define('DB_USERNAME', '*******');
define('DB_PASSWORD', '*******');
define('DB_DATABASE', '*******');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
$query = "SELECT user_id, username, user_password FROM User_Login WHERE username='$username' AND user_password='$password'",
$username = mysqli_real_escape_string($db,$_GET['username']),
$password = mysqli_real_escape_string($db,$_GET['password']);
// Perform Query
$result = mysqli_query($db,$query);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysqli_error($db) . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
// Use result
// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
while ($row = mysqli_fetch_assoc($result)) {
echo $row['$username'];
echo $row['username'];
echo $row['user_password'];
}
// Free the resources associated with the result set
// This is done automatically at the end of the script
mysqli_free_result($result);
?>
objFile = QFileDialog.getOpenFileName(self, 'Open File', '/home/user',
'My file (*.hello);; All File (*.*)'
)
的参数是:标题(&#34;打开文件&#34;),开始寻找的地方(可能是getOpenFileName
),以及不同类型的文件(这个最后是可选的)。此方法将str返回到文件的de url。