• 3312阅读
  • 1回复

请教一个 finddialog查找对话框的例子问题。。。。。。 [复制链接]

上一主题 下一主题
离线hx860812
 
只看楼主 正序阅读 楼主  发表于: 2009-03-31
下面部分代码源自:QT4.4.3中的Spreadsheet电子表的 例子。。
void Spreadsheet::findNext(const QString &str, Qt::CaseSensitivity cs)         //向前查找
{
    int row = currentRow();
    int column = currentColumn() + 1;
    while (row < RowCount) {
        while (column < ColumnCount) {
            if (text(row, column).contains(str, cs)) {
                clearSelection();
                setCurrentCell(row, column);
                activateWindow();

                return;
            }
            ++column;
        }
        column = 0;
        ++row;
    }
    QApplication::beep();
}

void Spreadsheet::findPrevious(const QString &str, Qt::CaseSensitivity cs)                 //向后查找
{
    int row = currentRow();
    int column = currentColumn() - 1;
    while (row >= 0) {
        while (column >= 0) {
            if (text(row, column).contains(str, cs)) {
               clearSelection();
                setCurrentCell(row, column);
                activateWindow();

                return;
            }
            --column;
        }
        column = ColumnCount - 1;
        --row;
    }
    QApplication::beep();
}
我用Qtabwidget和QTabelView写了个用页标显示不同列表的界面(用容器QList<QStringList>listofPairs存储数据) ,
我想用上面的部分代码实现查找功能,而上面电子表用的是QtabelWidget,
请问一下红色的 地方如何替换????
离线hx860812
只看该作者 1楼 发表于: 2009-03-31
UP!
快速回复
限100 字节
 
上一个 下一个