我有一个QTreeView和QFileSystemModel作为模型.
QTreeView将SelectionBehavior设置为SelectRows.
在我的代码中,我读了一个数据集来选择,然后通过以下方式选择它们:
idx = treeview->model()->index(search);
selection->select(idx, QItemSelectionModel::Select);
Run Code Online (Sandbox Code Playgroud)
这将选择一个单元格,而不是行..
添加了一个愚蠢的解决方法,但宁愿以正确的方式解决这个问题.
for (int col=0; col< treeview->model()->columnCount(); col++)
{
idx = treeview->model()->index(search, col);
selection->select(idx, QItemSelectionModel::Select);
}
Run Code Online (Sandbox Code Playgroud)
或者是^^唯一的方法吗?
我正在玩QFtp(是的......我知道)并且一切正常.
使用他们自己的示例中的代码作为指导.
http://doc.qt.io/archives/qt-4.7/network-qftp-ftpwindow-cpp.html
我遇到的唯一问题是发送(或接收)大文件(比方说3 GB)时,进度条会出现故障.
这是由于从qint64到int的强制转换:
void FtpWindow::updateDataTransferProgress(qint64 readBytes,
qint64 totalBytes)
{
progressDialog->setMaximum(totalBytes);
progressDialog->setValue(readBytes);
}
Run Code Online (Sandbox Code Playgroud)
我想知道在谷歌搜索大约一个小时之后处理这个问题最好的办法是什么,并通过确保我不会超出范围来确保它"安全".
while (totalBytes > 4294967295UL)
{
totalBytes = totalBytes/4294967295UL;
readBytes = readBytes/4294967295UL;
}
Run Code Online (Sandbox Code Playgroud)
但这并不"感觉"正确..