[[icons]]
 
#include <QDir>
 
void showDir (QTreeWidgetItem * target, QDir dir)
{
    QTreeWidgetItem * top = new QTreeWidgetItem;
    top->setText (0, dir.dirName());
    top->setToolTip (0, dir.path());
    top->setForeground (0, QColor ("red"));
    top->setIcon (0, QIcon::fromTheme ("folder"));
    target->addChild(top);
    QFileInfoList list = dir.entryInfoList (QDir::AllEntries | QDir::NoDotAndDotDot);
    for (QFileInfo file : list)
    {
        if (file.isDir())
           showDir (top, QDir (file.filePath()));
        else
        {
           QTreeWidgetItem * node = new QTreeWidgetItem;
           node->setText (0, file.fileName());
           node->setToolTip (0, file.absoluteFilePath());
           node->setForeground (0, QColor (0, 0, 255));
           node->setIcon (0, QIcon (file.filePath()));
           top->addChild(node);
        }
    }
}
 
void MainWindow::on_actionTest_triggered()
{
    QIcon::setThemeName("mate");
    QDir d ("/usr/share/icons");
    QDir dir (d.canonicalPath());
    showDir (ui->treeWidget->invisibleRootItem(), dir);
}
 
icons.txt · Last modified: 2019/03/04 17:11 by 147.32.8.115
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki