mp3上的setmodel.setattribute用法

set 的用法_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
set 的用法
&&英语学习 事例
阅读已结束,下载本文需要
想免费下载本文?
定制HR最喜欢的简历
你可能喜欢java中Set类接口的用法
在Java中使用Set,可以方便地将需要的类型,以集合类型保存在一个变量中.主要应用在显示列表.
Set是一个不包含重复元素的collection。更确切地讲,set 不包含满足 e1.equals(e2) 的元素对 e1 和
e2,并且最多包含一个 null 元素。正如其名称所暗示的,此接口模仿了数学上的 set 抽象。
以下是在JAVA中使用Set的范例
import java.util.*;
public class test {
public static void main(String[] args) {
&& // TODO
Auto-generated method stub
&& Set set=new
HashSet();
set.add("abc");
set.add("cde");
set.add("efg");
set.add("fgh");&&&
&& set.add("abc");
//重复的abc,set会自动将其去掉&&
System.out.println("size="+ set.size() );
&List list = new ArrayList();
list.add("abc");
list.add("aaa");
list.add("fff");
set.addAll(list); //将list中的值加入set,并去掉重复的abc
System.out.println("size="+ set.size() );
Iterator&& it =
set.iterator(); it.hasNext(); )
{&&&&&&&&&&&&&
&&&&&&&&&System.out.println("value="+it.next().toString());&&&&&&&&&&&&
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。I have been working on an application where I can traverse the system drives using QDirIterator and look for audio/video files, grab the details using QStandardItemModel and display it on QTreeview. I have been successful in displaying file name, type, size, date-modified but DURATION is something which I am not able to do.
Here is the code:
// Displays Files in Detail View on Clicking Drive
void DetailView::on_DriveView_clicked(const QModelIndex &index)
int m_count_row = 0;
QStandardItemModel *model = new QStandardItemModel(0,0);
QString sPath = pSystemModel-&fileInfo(index).absoluteFilePath();
pSystemTreeViewModel-&setRootPath(sPath);
ui-&DriveListView-&setRootIndex(pSystemTreeViewModel-&index(sPath));
pSystemModel-&setRootPath(QDir::currentPath());
pSystemModel-&setFilter(QDir::NoDotAndDotDot | QDir::AllDirs );
pSystemTreeViewModel-&setFilter( QDir::Files | QDir::NoDotAndDotDot );
QStringList m_
QDirIterator dirIt(sPath,QDirIterator::Subdirectories);
while (dirIt.hasNext())
dirIt.next();
if (QFileInfo(dirIt.filePath()).isFile())
if (QFileInfo(dirIt.filePath()).suffix() == "mp3" ||(QFileInfo(dirIt.filePath()).suffix() == "mts" ) ||(QFileInfo(dirIt.filePath()).suffix() == "m2ts" ))
m_list && dirIt.filePath();
QModelIndex m_index = model-&index(m_count_row, 0, QModelIndex());
model-&setHeaderData( 0, Qt::Horizontal, "Name" );
model-&setHeaderData( 1, Qt::Horizontal, "Type" );
model-&setHeaderData( 2, Qt::Horizontal, "Size" );
model-&setHeaderData( 3, Qt::Horizontal, "Date Modified" );
model-&setData( m_index, dirIt.fileName(), Qt::DecorationRole );
QStandardItem *itemName = new QStandardItem(dirIt.fileName());
model-&setItem(m_count_row, 0, itemName);
model-&setData( m_index, dirIt.fileInfo().suffix(), Qt::DecorationRole );
QStandardItem *itemExtention = new QStandardItem( dirIt.fileInfo().suffix());
model-&setItem(m_count_row, 1, itemExtention);
model-&setData( m_index, dirIt.fileInfo().size(), Qt::DecorationRole );
float fFileSize = dirIt.fileInfo().size();
float fFileKB = fFileSize / 1024; //kilobyte
float fFileMB = fFileKB / 1024; //megabyte
float fFinalSize = ceilf(fFileMB * 100) / 100;
QString sSizeValue = QString::number(fFinalSize);
QStandardItem *itemSize = new QStandardItem(sSizeValue + " MB");
model-&setItem(m_count_row, 2, itemSize);
model-&setData( m_index, dirIt.fileInfo().lastModified(), Qt::DecorationRole );
QDateTime m_time = dirIt.fileInfo().lastModified();
QString sTime = m_time.toString("dd/MM/yyyy hh:mm:ss");
QStandardItem *itemDate = new QStandardItem(sTime);
model-&setItem(m_count_row, 3, itemDate);
ui-&DriveListView-&setModel(model);
ui-&DriveListView-&setRootIsDecorated(false);
m_count_row++;
pSystemTreeViewModel-&setNameFilterDisables(false);
I am not sure whether I can get the duration using the above way since I couldn't find any such property. Is their any other way of doing it? I don want to use QMediaPlayer. Any other alternate solution which can help me update my above code with Duration???
解决方案 Using Qt
You can try exploring the Qt's .
in the Phonon's MediaObject class might be helpful in getting what you are trying to achieve.
P.S. Do read the warning written at the end of that function, to avoid getting wrong results.
Without using Qt
Read about TagLib Library . Check
function they have mentioned regarding getting the length of file. And it is under LGPL as well.
本文地址: &
我一直在使用一个应用程序,其中我可以使用 QDirIterator 遍历系统驱动器,并查找音频/视频文件,使用 QStandardItemModel 获取详细信息,并显示它QTreeview。我已成功显示文件名,类型,大小,更改日期,但 DURATION 是我无法做到的。
下面是代码:
//在点击驱动器时显示详细视图中的文件 void DetailView :: on_DriveView_clicked QModelIndex& index) { int m_count_row = 0;
QStandardItemModel * model = new QStandardItemModel(0,0);
QString sPath = pSystemModel-& fileInfo(index).absoluteFilePath();
pSystemTreeViewModel-& setRootPath(sPath);
ui-& DriveListView-& setRootIndex(pSystemTreeViewModel-& index(sPath));
pSystemModel-& setRootPath(QDir :: currentPath());
pSystemModel-& setFilter(QDir :: NoDotAndDotDot | QDir :: AllDirs);
pSystemTreeViewModel-& setFilter(QDir :: Files | QDir :: NoDotAndDotDot);
QStringList m_
QDirIterator dirIt(sPath,QDirIterator :: Subdirectories);
while(dirIt.hasNext()) { dirIt.next();
if(QFileInfo(dirIt.filePath())。isFile()) { if(QFileInfo(dirIt.filePath())。suffix()==“mp3”|| QFileInfo(dirIt.filePath())。suffix()==“mts”)||(QFileInfo(dirIt.filePath())。suffix()==“m2ts”)) { m_list && dirIt.filePath();
QModelIndex m_index = model-& index(m_count_row,0,QModelIndex());
model-& setHeaderData(0,Qt :: Horizontal,“Name”);
model-& setHeaderData(1,Qt :: Horizontal,“Type”);
model-& setHeaderData(2,Qt :: Horizontal,“Size”);
model-& setHeaderData(3,Qt :: Horizontal,“Date Modified”);
model-& setData(m_index,dirIt.fileName(),Qt :: DecorationRole);
QStandardItem * itemName = new QStandardItem(dirIt.fileName());
model-& setItem(m_count_row,0,itemName);
model-& setData(m_index,dirIt.fileInfo()。suffix(),Qt :: DecorationRole);
QStandardItem * itemExtention = new QStandardItem(dirIt.fileInfo()。suffix());
model-& setItem(m_count_row,1,itemExtention);
model-& setData(m_index,dirIt.fileInfo()。size(),Qt :: DecorationRole);
float fFileSize = dirIt.fileInfo()。size();
float fFileKB = fFileSize / 1024; // kilobyte
float fFileMB = fFileKB / 1024; // megabyte
float fFinalSize = ceilf(fFileMB * 100)/ 100;
QString sSizeValue = QString :: number(fFinalSize);
QStandardItem * itemSize = new QStandardItem(sSizeValue +“MB”);
model-& setItem(m_count_row,2,itemSize);
model-& setData(m_index,dirIt.fileInfo()。lastModified(),Qt :: DecorationRole);
QDateTime m_time = dirIt.fileInfo()。lastModified();
QString sTime = m_time.toString(“dd / MM / yyyy hh:mm:ss”);
QStandardItem * itemDate = new QStandardItem(sTime);
model-& setItem(m_count_row,3,itemDate);
ui-& DriveListView-& setModel(model);
ui-& DriveListView-& setRootIsDecorated(false);
m_count_row ++; } }
pSystemTreeViewModel-& setNameFilterDisables(false); } }
我不知道是否可以上面的方式,因为我找不到任何这样的属性。是他们的任何其他方式吗?我不想使用QMediaPlayer。任何其他替代解决方案,可以帮助我更新我的上述代码与持续时间?
可以尝试探索Qt的。
我认为 Phonon的MediaObject类可能有助于获得您想要实现的目标。
请阅读该函数末尾写的警告,以避免得到错误的结果。
编辑1: 不使用Qt
阅读有关TagLib库的信息。检查他们提及的有关获取文件长度的功能。它也是在LGPL以下。
本文地址: &
扫一扫关注官方微信java,setModel方法什么作用啊?_百度知道
java,setModel方法什么作用啊?
setModel方法说明作用啊?我查了AP实在是I没找到啊,哪位高手能给我讲解一下吗,就按自己的理解说一下啊,谢谢了
我有更好的答案求助知道网友
以JTable为例,API中说明如下:public void setModel(TableModel dataModel)将此表的数据模型设置为 newModel,并向其注册以获取来自新数据模型的侦听器通知。参数:dataModel - 此表的新数据源,TableModel 接口指定了 JTable 用于询问表格式数据模型的方法。定义了表格要展示的数据,并控制是否允许修改,数据更新的监听。
wing包javax.swing.*像包JComboBox、JMenu、JList、JMenuItem
本回答被网友采纳
1条折叠回答
为您推荐:
其他类似问题
java的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。}

我要回帖

更多关于 qtableview setmodel 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信