QT编程 获取当前工作目录下的文件列表,并以Tree的形式显示在界面上

QT编程 获取当前工作目录下的文件列表,并以Tree的形式显示在界面上,第1张

String[] s={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

Systemoutprint("请输入数字(1-12):");

BufferedReader br=new BufferedReader(new InputStreamReader(Systemin));

String str=brreadLine();

int m=IntegerparseInt(str);

if (m<=0||m>=13)

{

The method selectionModel() return a QItemSelectionModel

You can use QItemSelectionModel class to check/change/other selection(s)

Example:

QItemSelectionModel select = yourTableview->selectionModel();

select->hasSelection() //check if has selection

select->selectedRows() // return selected row(s)

select->selectedColumns() // return selected column(s)

Example:

QModelIndexList indexList = yourTableView->selectionModel()->selectedIndexes();

int row;

foreach (QModelIndex index, indexList) {

row = indexrow();

}

这个是根据该扩展名对应的打开程序指定的

有简单的方法改的

你选择 我的电脑->工具->文件夹选项->文件类型,选择你要改的扩展名,选择高级,然后选择更改图标就能选择你想要的图标了

如果是 QLineEdit,则用: QString str =  ui->edit->text();

如果是 QPlainTextEdit,则用: QString str =  ui->edit->toPlainText();

如果是 QTextEdit, 获取简单文本则用: QString str =  ui->edit->toPlainText(); 获取富文本则用:QString str =  ui->edit->toHtml(); 。

void Widget::keyPressEvent(QKeyEvent event)

{

switch (event->key())

{

case Qt::Key_Return:

focusNextPrevChild(true);

break;}

}

focusNextPrevChild(true);这是选下一个焦点的,返回当前的就在这附近,你帮助里找下,我就帮你找了。

Qt中获取控件的margin方法如下所示:

先通过getChildAt(intindex)获取到子控件,再通过lp=getLayoutParams()获取到子控件的参数,lpleftMargin就是你想要的数值。

#include "mainwindowh"

#include <QApplication>

#include <QDebug>

int main(int argc, char argv[])

{

    QApplication a(argc, argv);

    if (NULL != argv) {

        // 主函数入口,默认都带有一个参数,就是本程序的名字

        qDebug() << argv[0];

    }

    else

        qDebug() << "is null";

    MainWindow w;

    wshow();

    return aexec();

}

以上就是关于QT编程 获取当前工作目录下的文件列表并以Tree的形式显示在界面上全部的内容,包括:QT编程 获取当前工作目录下的文件列表,并以Tree的形式显示在界面上、QT中如何获取QTableView当前行的坐标、Qt如何获取指定类型的文件图标等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9324827.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-27
下一篇 2023-04-27

发表评论

登录后才能评论

评论列表(0条)

保存