Lendamand
8th September 2010, 04:52
It is my first time to post a question here, and I have a simple problem about Phonon::MediaSource class. Codes like this:
QString string = "It's ok.mp3";
Phonon::MediaSource source1(string);
Phonon::MediaSource source2(string);
if(source1 == source2)
{
qDebug("equal");
}
else
{
qDebug("not equal");
}
The output is "not equal".
why above codes will return false? And how to get true when I compare two MediaSources?
By the way, I am using the QList<Phonon::MediaSource> to store the MediaSources in my project, but I don't want to stroe the same source in it, I know that it should use the method QList::contains(MediaSource source) to decide whether the source has existed. of course, I fail. It will store the same mediasource more than once. I think it may have a relation to the 'MediaSource::operator== ( const MediaSource & other )'
QList<Phonon::MediaSource> sources;
Phonon::source1("it's ok.mp3");
Phonon::source2("it's ok.mp3");
if(!sources.contains(source1))
{
sources.append(source1);
}
if(!sources.contains(source2))
{
sources.append(source2);
}
Look forward to any suggestions or help. Thank you!
QString string = "It's ok.mp3";
Phonon::MediaSource source1(string);
Phonon::MediaSource source2(string);
if(source1 == source2)
{
qDebug("equal");
}
else
{
qDebug("not equal");
}
The output is "not equal".
why above codes will return false? And how to get true when I compare two MediaSources?
By the way, I am using the QList<Phonon::MediaSource> to store the MediaSources in my project, but I don't want to stroe the same source in it, I know that it should use the method QList::contains(MediaSource source) to decide whether the source has existed. of course, I fail. It will store the same mediasource more than once. I think it may have a relation to the 'MediaSource::operator== ( const MediaSource & other )'
QList<Phonon::MediaSource> sources;
Phonon::source1("it's ok.mp3");
Phonon::source2("it's ok.mp3");
if(!sources.contains(source1))
{
sources.append(source1);
}
if(!sources.contains(source2))
{
sources.append(source2);
}
Look forward to any suggestions or help. Thank you!