本文整理汇总了C++中setCurrentIndex函数的典型用法代码示例。如果您正苦于以下问题:C++ setCurrentIndex函数的具体用法?C++ setCurrentIndex怎么用?C++ setCurrentIndex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setCurrentIndex函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCurrentIndex
void TabWidget::slotNextTab()
{
setCurrentIndex((currentIndex()+1) % count());
}
示例2: setCurrentIndex
//! [1]
void ColorListEditor::setColor(QColor color)
{
setCurrentIndex(findData(color, int(Qt::DecorationRole)));
}
示例3: setProfileByCount
void CustomTabWidget::addTab(QWidget *widget, const QIcon &icon, const QString &label)
{
QTabWidget::addTab(widget,icon,label);
setProfileByCount();
setCurrentIndex(this->indexOf(widget));
}
示例4: setCurrentIndex
void WWidgetStack::onNextControlChanged(double v) {
if (v > 0.0) {
setCurrentIndex((currentIndex() + 1) % count());
}
}
示例5: q
void KexiCSVTextQuoteComboBox::setTextQuote(const QString& textQuote)
{
QString q(textQuote.isEmpty() ? xi18n("None") : textQuote);
setCurrentIndex(findText(q));
}
示例6: currentIndex
void QgsLocatorResultsView::selectNextResult()
{
int nextRow = currentIndex().row() + 1;
nextRow = nextRow % model()->rowCount( QModelIndex() );
setCurrentIndex( model()->index( nextRow, 0 ) );
}
示例7: qDebug
Tomahawk::result_ptr
TrackProxyModel::siblingItem( int itemsAway, bool readOnly )
{
qDebug() << Q_FUNC_INFO;
QModelIndex idx = index( 0, 0 );
if ( rowCount() )
{
if ( m_shuffled )
{
// random mode is enabled
// TODO come up with a clever random logic, that keeps track of previously played items
idx = index( qrand() % rowCount(), 0 );
}
else if ( currentIndex().isValid() )
{
idx = currentIndex();
// random mode is disabled
if ( m_repeatMode != PlaylistInterface::RepeatOne )
{
// keep progressing through the playlist normally
idx = index( idx.row() + itemsAway, 0 );
}
}
}
if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll )
{
// repeat all tracks
if ( itemsAway > 0 )
{
// reset to first item
idx = index( 0, 0 );
}
else
{
// reset to last item
idx = index( rowCount() - 1, 0 );
}
}
// Try to find the next available PlaylistItem (with results)
while ( idx.isValid() )
{
TrackModelItem* item = itemFromIndex( mapToSource( idx ) );
if ( item && item->query()->playable() )
{
qDebug() << "Next PlaylistItem found:" << item->query()->toString() << item->query()->results().at( 0 )->url();
if ( !readOnly )
setCurrentIndex( idx );
return item->query()->results().at( 0 );
}
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0 );
}
if ( !readOnly )
setCurrentIndex( QModelIndex() );
return Tomahawk::result_ptr();
}
示例8: setCurrentIndex
void WStackedWidget::setCurrentIndex(int index)
{
setCurrentIndex(index, animation_, autoReverseAnimation_);
}
示例9: setCurrentIndex
void ListingTable::setCurrentPart(unsigned int id)
{
setCurrentIndex(model->getIndexWithID(id));
}
示例10: setCurrentIndex
void StackedWidget::selectPage( int index )
{
if( index >= 0 && index < count() )
setCurrentIndex( index );
}
示例11: QWidget
Menu::Menu(QWidget *parent):
QWidget(parent)
{
setObjectName("Menu");
isStay=isPoped=false;
Utils::setGround(this,Qt::white);
fileL=new QLineEdit(this);
danmL=new QLineEdit(this);
sechL=new QLineEdit(this);
fileL->installEventFilter(this);
danmL->installEventFilter(this);
sechL->installEventFilter(this);
fileL->setReadOnly(true);
fileL->setPlaceholderText(tr("choose a local media"));
danmL->setPlaceholderText(tr("input av/ac number"));
sechL->setPlaceholderText(tr("search danmaku online"));
fileL->setGeometry(QRect(10,25, 120,25));
danmL->setGeometry(QRect(10,65, 120,25));
sechL->setGeometry(QRect(10,105,120,25));
connect(danmL,&QLineEdit::textEdited,[this](QString text){
QRegularExpression regexp("(av|ac|dd)((\\d+)([#_])?(\\d+)?)?|[ad]");
regexp.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
auto iter=regexp.globalMatch(text);
QString match;
while(iter.hasNext()){
match=iter.next().captured();
}
danmL->setText(match.toLower().replace('_','#'));
});
danmC=new QCompleter(new LoadModelWapper(Load::instance()->getModel(),tr("Load All")),this);
danmC->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
danmC->setCaseSensitivity(Qt::CaseInsensitive);
danmC->setWidget(danmL);
QAbstractItemView *popup=danmC->popup();
popup->setMouseTracking(true);
connect(popup,SIGNAL(entered(QModelIndex)),popup,SLOT(setCurrentIndex(QModelIndex)));
connect<void (QCompleter::*)(const QModelIndex &)>(danmC,&QCompleter::activated,[this](const QModelIndex &index){
QVariant v=index.data(Load::UrlRole);
if(!v.isNull()&&!v.toUrl().isValid()){
Load::instance()->loadDanmaku();
}
else{
Load::instance()->loadDanmaku(index);
}
});
fileB=new QPushButton(this);
sechB=new QPushButton(this);
danmB=new QPushButton(this);
fileB->setGeometry(QRect(135,25, 55,25));
danmB->setGeometry(QRect(135,65, 55,25));
sechB->setGeometry(QRect(135,105,55,25));
fileB->setText(tr("Open"));
danmB->setText(tr("Load"));
sechB->setText(tr("Search"));
fileA=new QAction(tr("Open File"),this);
fileA->setObjectName("File");
fileA->setShortcut(Config::getValue("/Shortcut/File",QString()));
danmA=new QAction(tr("Load Danmaku"),this);
danmA->setObjectName("Danm");
danmA->setShortcut(Config::getValue("/Shortcut/Danm",QString()));
sechA=new QAction(tr("Search Danmaku"),this);
sechA->setObjectName("Sech");
sechA->setShortcut(Config::getValue("/Shortcut/Sech",QString()));
connect(fileA,&QAction::triggered,[this](){
QString _file=QFileDialog::getOpenFileName(Local::mainWidget(),
tr("Open File"),
Utils::defaultPath(),
tr("Media files (%1);;All files (*.*)").arg(Utils::getSuffix(Utils::Video|Utils::Audio,"*.%1").join(' ')));
if(!_file.isEmpty()){
APlayer::instance()->setMedia(_file);
}
});
connect(danmA,&QAction::triggered,[this](){
if(Config::getValue("/Danmaku/Local",false)){
QString _file=QFileDialog::getOpenFileName(Local::mainWidget(),
tr("Open File"),
Utils::defaultPath(),
tr("Danmaku files (%1);;All files (*.*)").arg(Utils::getSuffix(Utils::Danmaku,"*.%1").join(' ')));
if(!_file.isEmpty()){
Load::instance()->loadDanmaku(_file);
}
}
else{
if(danmL->text().isEmpty()){
pop();
isStay=true;
danmL->setFocus();
}
else{
Load::instance()->loadDanmaku(danmL->text());
}
}
});
connect(sechA,&QAction::triggered,[this](){
Search searchBox(Local::mainWidget());
sechL->setText(sechL->text().simplified());
if(!sechL->text().isEmpty()){
searchBox.setKey(sechL->text());
}
if(searchBox.exec()) {
//.........这里部分代码省略.........
示例12: setCurrentIndex
void ItemViewWidget::updateDropSelection()
{
setCurrentIndex(getIndex(qBound(0, m_dropRow, getRowCount()), 0));
m_dropRow = -1;
}
示例13: tabData
void PlaylistTabBar::Close() {
if (menu_index_ == -1) return;
const int playlist_id = tabData(menu_index_).toInt();
QSettings s;
s.beginGroup(kSettingsGroup);
const bool ask_for_delete = s.value("warn_close_playlist", true).toBool();
if (ask_for_delete && !manager_->IsPlaylistFavorite(playlist_id) &&
!manager_->playlist(playlist_id)->GetAllSongs().empty()) {
QMessageBox confirmation_box;
confirmation_box.setWindowIcon(QIcon(":/icon.png"));
confirmation_box.setWindowTitle(tr("Remove playlist"));
confirmation_box.setIcon(QMessageBox::Question);
confirmation_box.setText(
tr("You are about to remove a playlist which is not part of your "
"favorite playlists: "
"the playlist will be deleted (this action cannot be undone). \n"
"Are you sure you want to continue?"));
confirmation_box.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
QCheckBox dont_prompt_again(tr("Warn me when closing a playlist tab"),
&confirmation_box);
dont_prompt_again.setChecked(ask_for_delete);
dont_prompt_again.blockSignals(true);
dont_prompt_again.setToolTip(
tr("This option can be changed in the \"Behavior\" preferences"));
QGridLayout* grid = qobject_cast<QGridLayout*>(confirmation_box.layout());
QDialogButtonBox* buttons = confirmation_box.findChild<QDialogButtonBox*>();
if (grid && buttons) {
const int index = grid->indexOf(buttons);
int row, column, row_span, column_span = 0;
grid->getItemPosition(index, &row, &column, &row_span, &column_span);
QLayoutItem* buttonsItem = grid->takeAt(index);
grid->addWidget(&dont_prompt_again, row, column, row_span, column_span,
Qt::AlignLeft | Qt::AlignTop);
grid->addItem(buttonsItem, ++row, column, row_span, column_span);
} else {
confirmation_box.addButton(&dont_prompt_again, QMessageBox::ActionRole);
}
if (confirmation_box.exec() != QMessageBox::Yes) {
return;
}
// If user changed the pref, save the new one
if (dont_prompt_again.isChecked() != ask_for_delete) {
s.setValue("warn_close_playlist", dont_prompt_again.isChecked());
}
}
// Close the playlist. If the playlist is not a favorite playlist, it will be
// deleted, as it will not be visible after being closed. Otherwise, the tab
// is closed but the playlist still exists and can be resurrected from the
// "Playlists" tab.
emit Close(playlist_id);
// Select the nearest tab.
if (menu_index_ > 1) {
setCurrentIndex(menu_index_ - 1);
}
// Update playlist tab order/visibility
TabMoved();
}
示例14: switch
void TimelineView::keyPressEvent(QKeyEvent *event){
int i, next;
if(!event->modifiers().testFlag(Qt::ShiftModifier) &&
!event->modifiers().testFlag(Qt::ControlModifier) &&
!event->modifiers().testFlag(Qt::AltModifier)){
switch(event->key()){
case Qt::Key_M:
next = -1;
for(i=model()->baseIndex()-1; i>=0; i--){
if(isRelatedPost(i, model()->baseIndex())){
next = i;
break;
}
}
if(next>=0) setCurrentIndex(model()->index(next,currentIndex().column()));
return;
case Qt::Key_N:
next = -1;
for(i=model()->baseIndex()+1; i<model()->count(); i++){
if(isRelatedPost(i, model()->baseIndex())){
next = i;
break;
}
}
if(next>=0) setCurrentIndex(model()->index(next,currentIndex().column()));
return;
case Qt::Key_I:
emit favorite();
return;
case Qt::Key_H:
next = -1;
for(i=model()->baseIndex()+1; i<model()->count(); i++){
if(model()->itemAt(i).userId() == model()->itemAt(model()->baseIndex()).userId()){
next = i;
break;
}
}
if(next>=0) setCurrentIndex(model()->index(next,currentIndex().column()));
return;
case Qt::Key_J:
QApplication::sendEvent(this, &QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier));
return;
case Qt::Key_K:
QApplication::sendEvent(this, &QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier));
return;
case Qt::Key_L:
next = -1;
for(i=model()->baseIndex()-1; i>=0; i--){
if(model()->itemAt(i).userId() == model()->itemAt(model()->baseIndex()).userId()){
next = i;
break;
}
}
if(next>=0) setCurrentIndex(model()->index(next,currentIndex().column()));
return;
case Qt::Key_Space:
jumpToUnread();
return;
case Qt::Key_Return:
emit reply();
return;
default:
break;
}
}
if(event->modifiers().testFlag(Qt::ShiftModifier) &&
!event->modifiers().testFlag(Qt::ControlModifier) &&
!event->modifiers().testFlag(Qt::AltModifier)){
switch(event->key()){
case Qt::Key_M:
next = -1;
for(i=model()->baseIndex()-1; i>=0; i--){
if(model()->itemAt(i).favorited()){
next = i;
break;
}
}
if(next>=0) setCurrentIndex(model()->index(next,currentIndex().column()));
return;
case Qt::Key_N:
next = -1;
for(i=model()->baseIndex()+1; i<model()->count(); i++){
if(model()->itemAt(i).favorited()){
next = i;
break;
}
}
if(next>=0) setCurrentIndex(model()->index(next,currentIndex().column()));
return;
}
}
QTreeView::keyPressEvent(event);
}
示例15: setCurrentIndex
void PlaylistTabBar::set_current_id(int id) { setCurrentIndex(index_of(id)); }