小编the*_*inX的帖子

以编程方式在QTreeView中选择一行

我有一个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)

或者是^^唯一的方法吗?

c++ qt qt4 qtreeview

18
推荐指数
2
解决办法
2万
查看次数

Qt托盘图标拖放

有谁知道是否可以使用Qt使用托盘图标拖放?

c++ qt drag-and-drop qt4

6
推荐指数
1
解决办法
1239
查看次数

如何很好地将Qint64"转换"为QProgressBar的int

我正在玩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)

但这并不"感觉"正确..

c++ qt qt4 integer-overflow

4
推荐指数
1
解决办法
6298
查看次数

标签 统计

c++ ×3

qt ×3

qt4 ×3

drag-and-drop ×1

integer-overflow ×1

qtreeview ×1