本文整理汇总了C++中QList::mid方法的典型用法代码示例。如果您正苦于以下问题:C++ QList::mid方法的具体用法?C++ QList::mid怎么用?C++ QList::mid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QList
的用法示例。
在下文中一共展示了QList::mid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setSizes
void HistoryMessagesTab::setSizes(const QList<int> &newSizes)
{
Q_ASSERT(newSizes.size() == 4);
Splitter->setSizes(newSizes.mid(0, 2));
TimelineView->setSizes(newSizes.mid(2, 2));
}
示例2: sizes
void tst_QColumnView::sizes()
{
QColumnView view;
QCOMPARE(view.columnWidths().count(), 0);
QList<int> newSizes;
newSizes << 10 << 4 << 50 << 6;
QList<int> visibleSizes;
view.setColumnWidths(newSizes);
QCOMPARE(view.columnWidths(), visibleSizes);
QDirModel model;
view.setModel(&model);
QModelIndex home = model.index(QDir::homePath());
view.setCurrentIndex(home);
QList<int> postSizes = view.columnWidths().mid(0, newSizes.count());
QCOMPARE(postSizes, newSizes.mid(0, postSizes.count()));
QVERIFY(view.columnWidths().count() > 1);
QList<int> smallerSizes;
smallerSizes << 6;
view.setColumnWidths(smallerSizes);
QList<int> expectedSizes = newSizes;
expectedSizes[0] = 6;
postSizes = view.columnWidths().mid(0, newSizes.count());
QCOMPARE(postSizes, expectedSizes.mid(0, postSizes.count()));
}
示例3: update
void Generator::update()
{
m_error.clear();
LanguageSettings settings("Current");
m_dictionary_url = settings.dictionary();
// Load dice
QString dice_path = settings.dice();
if (dice_path != m_dice_path) {
m_dice_path.clear();
m_dice.clear();
m_dice_large.clear();
QList<QStringList> dice;
QFile file(dice_path);
if (file.open(QFile::ReadOnly | QIODevice::Text)) {
QTextStream stream(&file);
stream.setCodec("UTF-8");
while (!stream.atEnd()) {
QStringList line = stream.readLine().split(',', QString::SkipEmptyParts);
if (line.count() == 6) {
dice.append(line);
}
}
file.close();
}
if (dice.count() == 41) {
m_dice_path = dice_path;
m_dice = dice.mid(0, 16);
m_dice_large = dice.mid(16);
} else {
m_dice = m_dice_large = QList<QStringList>() << QStringList("?");
return setError(tr("Unable to read dice from file."));
}
}
// Load words
QString words_path = settings.words();
if (words_path != m_words_path) {
m_words_path.clear();
m_words.clear();
int count = 0;
// Load cached words
QString cache_dir = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/cache";
QString cache_file = QCryptographicHash::hash(words_path.toUtf8(), QCryptographicHash::Sha1).toHex();
QFileInfo cache_info(cache_dir + "/" + cache_file);
if (cache_info.exists() && (cache_info.lastModified() > QFileInfo(words_path).lastModified())) {
QFile file(cache_info.absoluteFilePath());
if (file.open(QFile::ReadOnly)) {
QDataStream stream(&file);
quint32 magic, version;
stream >> magic >> version;
if ((magic == 0x54524945) && (version == 1)) {
stream.setVersion(QDataStream::Qt_4_6);
stream >> m_words;
count = !m_words.isEmpty() * -1;
}
示例4: Simplified
static TemplateList Simplified(const TemplateList &templates)
{
TemplateList simplified;
foreach (const Template &t, templates) {
if (t.isEmpty()) {
if (!t.file.getBool("enrollAll"))
simplified.append(t);
continue;
}
const bool fte = t.file.getBool("FTE");
QList<QPointF> landmarks = t.file.landmarks();
QList<QRectF> ROIs = t.file.ROIs();
if (landmarks.size() % t.size() != 0) qFatal("TemplateList::simplified uneven landmark count.");
if (ROIs.size() % t.size() != 0) qFatal("TemplateList::simplified uneven ROI count.");
const int landmarkStep = landmarks.size() / t.size();
const int ROIStep = ROIs.size() / t.size();
for (int i=0; i<t.size(); i++) {
if (!fte || !t.file.getBool("enrollAll")) {
simplified.append(Template(t.file, t[i]));
simplified.last().file.setROIs(ROIs.mid(i*ROIStep, ROIStep));
simplified.last().file.setLandmarks(landmarks.mid(i*landmarkStep, landmarkStep));
}
}
}
return simplified;
}
示例5: updataData
void widgetTest::updataData(QList<qint16> listData)
{
//0-400 X
XWidget->updateDate(listData.mid(0,WAVE_LENGHT_VALUE));
//400-800 Y
YWidget->updateDate(listData.mid(WAVE_LENGHT_VALUE-1,WAVE_LENGHT_VALUE));
//800-1200 X'
XxWidget->updateDate(listData.mid(2*WAVE_LENGHT_VALUE-1,WAVE_LENGHT_VALUE));
//1200-1600 Y'
YyWidget->updateDate(listData.mid(3*WAVE_LENGHT_VALUE-1,WAVE_LENGHT_VALUE));
}
示例6: onSearchMovieFinished
/**
* @brief Called when the search result was downloaded
* Emits "sigSearchDone" if there are no more pages in the result set
* @param results List of results from scraper
* @see TMDb::parseSearch
*/
void FanartTv::onSearchMovieFinished(QList<ScraperSearchResult> results)
{
if (m_searchResultLimit == 0)
emit sigSearchDone(results);
else
emit sigSearchDone(results.mid(0, m_searchResultLimit));
}
示例7: Match
QList<Team> FourMatchesContest::teamsAvailableToPlayAgainst(const Team& team, const QList<Team> &teamsToPlayAgainst )
{
QList<Team> ret = teamsToPlayAgainst.mid( 1 );
for( int i = 0; i < ret.size(); ++i ) {
Team currentTeam = ret.at( i );
if( currentTeam == team ) continue;
bool alreadyExists = false;
if ( mFirstPhase != NULL ) {
alreadyExists |= mFirstPhase->exists( Match( team, currentTeam ) )
|| mFirstPhase->exists( Match( currentTeam, team ) );
}
if ( mSecondPhase != NULL ) {
alreadyExists |= mSecondPhase->exists( Match( team, currentTeam ) )
|| mSecondPhase->exists( Match( currentTeam, team ) );
}
if ( mThirdPhase != NULL ) {
alreadyExists |= mThirdPhase->exists( Match( team, currentTeam ) )
|| mThirdPhase->exists( Match( currentTeam, team ) );
}
if ( mFourthPhase != NULL ) {
alreadyExists |= mFourthPhase->exists( Match( team, currentTeam ) )
|| mFourthPhase->exists( Match( currentTeam, team ) );
}
if ( alreadyExists ) {
ret.removeAt( i );
--i;
}
}
return ret;
}
示例8: onSearchTvShowFinished
/**
* @brief TheTvDbImages::onSearchTvShowFinished
* @param results Result list
*/
void TheTvDbImages::onSearchTvShowFinished(QList<ScraperSearchResult> results)
{
if (m_searchResultLimit == 0)
emit sigSearchDone(results);
else
emit sigSearchDone(results.mid(0, m_searchResultLimit));
}
示例9: insertGap
bool QToolBarAreaLayout::insertGap(const QList<int> &path, QLayoutItem *item)
{
Q_ASSERT(path.count() == 3);
const int i = path.first();
Q_ASSERT(i >= 0 && i < QInternal::DockCount);
return docks[i].insertGap(path.mid(1), item);
}
示例10: resultsAction
void SearchController::resultsAction()
{
checkParams({"id"});
const int id = params()["id"].toInt();
int limit = params()["limit"].toInt();
int offset = params()["offset"].toInt();
const auto searchHandlers = sessionManager()->session()->getData<SearchHandlerDict>(SEARCH_HANDLERS);
if (!searchHandlers.contains(id))
throw APIError(APIErrorType::NotFound);
const SearchHandlerPtr searchHandler = searchHandlers[id];
const QList<SearchResult> searchResults = searchHandler->results();
const int size = searchResults.size();
if (offset > size)
throw APIError(APIErrorType::Conflict, tr("Offset is out of range"));
// normalize values
if (offset < 0)
offset = size + offset;
if (offset < 0) // check again
throw APIError(APIErrorType::Conflict, tr("Offset is out of range"));
if (limit <= 0)
limit = -1;
if ((limit > 0) || (offset > 0))
setResult(getResults(searchResults.mid(offset, limit), searchHandler->isActive(), size));
else
setResult(getResults(searchResults, searchHandler->isActive(), size));
}
示例11: onSearchMovieFinished
void MediaPassionImages::onSearchMovieFinished(QList<ScraperSearchResult> results)
{
if (m_searchResultLimit == 0)
emit sigSearchDone(results);
else
emit sigSearchDone(results.mid(0, m_searchResultLimit));
}
示例12: ensureChachePopulated
QList<NoteListItem> FileStorage::noteList(int limit)
{
ensureChachePopulated();
QList<NoteListItem> ret = cache.values();
qSort(ret.begin(), ret.end(), noteListItemModifyComparer);
// probably sort is unnecesary here if the only accessor is notemanager which also does sorting.
return limit ? ret.mid(0, limit) : ret;
}
示例13: mid
void tst_QList::mid() const
{
QList<QString> list;
list << "foo" << "bar" << "baz" << "bak" << "buck" << "hello" << "kitty";
QCOMPARE(list.mid(3, 3),
QList<QString>() << "bak" << "buck" << "hello");
}
示例14: onSearchMovieFinished
/**
* @brief Called when the search result was downloaded
* Emits "sigSearchDone" if there are no more pages in the result set
* @param results List of results from scraper
* @see TMDb::parseSearch
*/
void TMDbImages::onSearchMovieFinished(QList<ScraperSearchResult> results)
{
qDebug() << "Entered";
if (m_searchResultLimit == 0)
emit sigSearchDone(results);
else
emit sigSearchDone(results.mid(0, m_searchResultLimit));
}
示例15:
void
ArtistInfoWidget::onTracksFound( const QList<Tomahawk::query_ptr>& queries, ModelMode mode )
{
Q_UNUSED( mode );
m_topHitsModel->finishLoading();
m_topHitsModel->appendQueries( queries.mid( 0, 20 ) );
}