本文整理汇总了C++中setCurrentIndex函数的典型用法代码示例。如果您正苦于以下问题:C++ setCurrentIndex函数的具体用法?C++ setCurrentIndex怎么用?C++ setCurrentIndex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setCurrentIndex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setCurrentIndex
void TabWidget::slotNextTab()
{
setCurrentIndex((currentIndex()+1) % count());
}
开发者ID:mschuett,项目名称:akregator,代码行数:4,代码来源:tabwidget.cpp
示例2: setCurrentIndex
//! [1]
void ColorListEditor::setColor(QColor color)
{
setCurrentIndex(findData(color, int(Qt::DecorationRole)));
}
开发者ID:Afreeca,项目名称:qt,代码行数:5,代码来源:colorlisteditor.cpp
示例3: setProfileByCount
void CustomTabWidget::addTab(QWidget *widget, const QIcon &icon, const QString &label)
{
QTabWidget::addTab(widget,icon,label);
setProfileByCount();
setCurrentIndex(this->indexOf(widget));
}
开发者ID:BruceZCQ,项目名称:Qt-Area-Network-Teaching-System,代码行数:6,代码来源:customtabwidget.cpp
示例4: setCurrentIndex
void WWidgetStack::onNextControlChanged(double v) {
if (v > 0.0) {
setCurrentIndex((currentIndex() + 1) % count());
}
}
开发者ID:AlbanBedel,项目名称:mixxx,代码行数:5,代码来源:wwidgetstack.cpp
示例5: q
void KexiCSVTextQuoteComboBox::setTextQuote(const QString& textQuote)
{
QString q(textQuote.isEmpty() ? xi18n("None") : textQuote);
setCurrentIndex(findText(q));
}
开发者ID:foren197316,项目名称:calligra,代码行数:5,代码来源:kexicsvwidgets.cpp
示例6: currentIndex
void QgsLocatorResultsView::selectNextResult()
{
int nextRow = currentIndex().row() + 1;
nextRow = nextRow % model()->rowCount( QModelIndex() );
setCurrentIndex( model()->index( nextRow, 0 ) );
}
开发者ID:aaime,项目名称:QGIS,代码行数:6,代码来源:qgslocatorwidget.cpp
示例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();
}
开发者ID:eninja,项目名称:tomahawk,代码行数:61,代码来源:trackproxymodel.cpp
示例8: setCurrentIndex
void WStackedWidget::setCurrentIndex(int index)
{
setCurrentIndex(index, animation_, autoReverseAnimation_);
}
开发者ID:bytemaster,项目名称:wt-1,代码行数:4,代码来源:WStackedWidget.C
示例9: setCurrentIndex
void ListingTable::setCurrentPart(unsigned int id)
{
setCurrentIndex(model->getIndexWithID(id));
}
开发者ID:alemariusnexus,项目名称:electronicsdb,代码行数:4,代码来源:ListingTable.cpp
示例10: setCurrentIndex
void StackedWidget::selectPage( int index )
{
if( index >= 0 && index < count() )
setCurrentIndex( index );
}
开发者ID:petrpopov,项目名称:db_transactions,代码行数:5,代码来源:stackedwidget.cpp
示例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()) {
//.........这里部分代码省略.........
开发者ID:laochangxin,项目名称:BiliLocal,代码行数:101,代码来源:Menu.cpp
示例12: setCurrentIndex
void ItemViewWidget::updateDropSelection()
{
setCurrentIndex(getIndex(qBound(0, m_dropRow, getRowCount()), 0));
m_dropRow = -1;
}
开发者ID:DoctorJellyface,项目名称:otter-browser,代码行数:6,代码来源:ItemViewWidget.cpp
示例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();
}
开发者ID:Gu1,项目名称:Clementine,代码行数:68,代码来源:playlisttabbar.cpp
示例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);
}
开发者ID:plus7,项目名称:Qween,代码行数:94,代码来源:timelineview.cpp
示例15: setCurrentIndex
void PlaylistTabBar::set_current_id(int id) { setCurrentIndex(index_of(id)); }
开发者ID:Gu1,项目名称:Clementine,代码行数:1,代码来源:playlisttabbar.cpp
示例16: setCurrentIndex
/*!
* This is a convenience function that sets a specific row as being selected.
* One can accomplish the same thing using setCurrentIndex() and index() on the
* model, but this is far easier.
*
* \param r The desired row.
*/
void CSIconListWidget::setSelectedRow(int r)
{
if(model() == NULL) return;
setCurrentIndex(model()->index(r, 0));
}
开发者ID:CmdrMoozy,项目名称:cutesync,代码行数:12,代码来源:iconlistwidget.cpp
示例17: fileInfo
void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw,
const QString& keyFile)
{
QFileInfo fileInfo(fileName);
QString canonicalFilePath = fileInfo.canonicalFilePath();
if (canonicalFilePath.isEmpty()) {
MessageBox::warning(this, tr("Warning"), tr("File not found!"));
return;
}
QHashIterator<Database*, DatabaseManagerStruct> i(m_dbList);
while (i.hasNext()) {
i.next();
if (i.value().canonicalFilePath == canonicalFilePath) {
setCurrentIndex(databaseIndex(i.key()));
return;
}
}
DatabaseManagerStruct dbStruct;
// test if we can read/write or read the file
QFile file(fileName);
if (!file.open(QIODevice::ReadWrite)) {
if (!file.open(QIODevice::ReadOnly)) {
MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n")
.append(file.errorString()));
return;
}
else {
// can only open read-only
dbStruct.readOnly = true;
}
}
file.close();
QLockFile* lockFile = new QLockFile(QString("%1/.%2.lock").arg(fileInfo.canonicalPath(), fileInfo.fileName()));
lockFile->setStaleLockTime(0);
if (!dbStruct.readOnly && !lockFile->tryLock()) {
// for now silently ignore if we can't create a lock file
// due to lack of permissions
if (lockFile->error() != QLockFile::PermissionError) {
QMessageBox::StandardButton result = MessageBox::question(this, tr("Open database"),
tr("The database you are trying to open is locked by another instance of KeePassX.\n"
"Do you want to open it anyway? Alternatively the database is opened read-only."),
QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::No) {
dbStruct.readOnly = true;
delete lockFile;
lockFile = nullptr;
}
else {
// take over the lock file if possible
if (lockFile->removeStaleLockFile()) {
lockFile->tryLock();
}
}
}
}
Database* db = new Database();
dbStruct.dbWidget = new DatabaseWidget(db, this);
dbStruct.lockFile = lockFile;
dbStruct.saveToFilename = !dbStruct.readOnly;
dbStruct.filePath = fileInfo.absoluteFilePath();
dbStruct.canonicalFilePath = canonicalFilePath;
dbStruct.fileName = fileInfo.fileName();
insertDatabase(db, dbStruct);
updateLastDatabases(dbStruct.filePath);
if (!pw.isNull() || !keyFile.isEmpty()) {
dbStruct.dbWidget->switchToOpenDatabase(dbStruct.filePath, pw, keyFile);
}
else {
dbStruct.dbWidget->switchToOpenDatabase(dbStruct.filePath);
}
}
开发者ID:irishken,项目名称:keepassx,代码行数:83,代码来源:DatabaseTabWidget.cpp
示例18: item_inserted_into_shortcut_model
void OptionsDialog::item_inserted_into_shortcut_model(size_t index){
auto lv = this->ui->shortcuts_list_view;
lv->setCurrentIndex(this->sl_model->create_index((int)index));
this->ui->add_button->setEnabled(false);
}
开发者ID:Helios-vmg,项目名称:Borderless,代码行数:5,代码来源:OptionsDialog.cpp
示例19: setCurrentIndex
void QmlConsoleProxyModel::selectEditableRow(const QModelIndex &index,
QItemSelectionModel::SelectionFlags command)
{
emit setCurrentIndex(mapFromSource(index), command);
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:5,代码来源:qmlconsoleproxymodel.cpp
示例20: setCurrentIndex
void QQueryResultView::showTabData()
{
setCurrentIndex(0);
}
开发者ID:Jet1oeil,项目名称:opendbviewer,代码行数:4,代码来源:QQueryResultView.cpp
注:本文中的setCurrentIndex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论