本文整理汇总了C++中QStackedWidget::currentIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ QStackedWidget::currentIndex方法的具体用法?C++ QStackedWidget::currentIndex怎么用?C++ QStackedWidget::currentIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStackedWidget
的用法示例。
在下文中一共展示了QStackedWidget::currentIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTabLogDiffVisible
void RevsView::setTabLogDiffVisible(bool b) {
QStackedWidget* s = tab()->stackedPanes;
QTabWidget* t = tab()->tabLogDiff;
bool isTabPage = (s->currentIndex() == 0);
int idx = (isTabPage ? t->currentIndex() : s->currentIndex());
container->setUpdatesEnabled(false);
if (b && !isTabPage) {
t->addTab(tab()->textBrowserDesc, "Log");
t->addTab(tab()->textEditDiff, "Diff");
t->setCurrentIndex(idx - 1);
s->setCurrentIndex(0);
}
if (!b && isTabPage) {
s->addWidget(tab()->textBrowserDesc);
s->addWidget(tab()->textEditDiff);
// manually remove the two remaining empty pages
t->removeTab(0); t->removeTab(0);
s->setCurrentIndex(idx + 1);
}
container->setUpdatesEnabled(true);
}
示例2: currentIndex
int QStackedWidgetProto::currentIndex() const
{
QStackedWidget *item = qscriptvalue_cast<QStackedWidget*>(thisObject());
if (item)
return item->currentIndex();
return 0;
}
示例3: nextWidgetIndex
int GoToStackPageAction::nextWidgetIndex() const
{
QStackedWidget *stack = qobject_cast<QStackedWidget*>(m_receiver);
if (!stack)
return -1;
return stack->currentIndex() + (m_direction == Previous ? -1 : 1);
}
示例4: toggleDiffView
void RevsView::toggleDiffView() {
QStackedWidget* s = tab()->stackedPanes;
QTabWidget* t = tab()->tabLogDiff;
bool isTabPage = (s->currentIndex() == 0);
int idx = (isTabPage ? t->currentIndex() : s->currentIndex());
bool old = container->updatesEnabled();
container->setUpdatesEnabled(false);
if (isTabPage)
t->setCurrentIndex(1 - idx);
else
s->setCurrentIndex(3 - idx);
container->setUpdatesEnabled(old);
}
示例5: if
void Form3::keyPressEvent(QKeyEvent * ev) {
QStackedWidget *sw = ui->stackedWidget;
//if(!testEnabled) return;
bool ok;
ix = sw->currentIndex();
int key = ev->key();
if(key == Qt::Key_F12) {
if(testMode == true) {
QMessageBox mb;
//mb.setText(tr("Ручная правка данных отключена"));
//mb.setInformativeText( tr("Чтение из аппаратуры восстановлено") );
mb.exec();
testMode=false;
}
}
else if(key == Qt::Key_F11) {
QString text = QInputDialog::getText(this,
"",//tr("Ручная правка данных"),
"",//tr("Чтение из аппаратуры выключено. Введите через запятую: адрес, значение"),
QLineEdit::Normal, 0, &ok);
if (ok && !text.isEmpty()) {
QStringList slist = text.split(",");
int dev=slist[0].toInt(&ok); if(!ok) return;
int adr=slist[1].toInt(&ok); if(!ok) return;
int val=slist[2].toInt(&ok); if(!ok) return;
valData[dev][adr] = val;
}
testMode = true;
}
else if(key == Qt::Key_Backspace) {
ref->show();
ref->setFocus();
}
else if(key == Qt::Key_Slash) { // меню ППН
if(ix==12) { // только для
ppnRef->show();
ppnRef->setFocus();
}
}
else
if(key == Qt::Key_Right) { // след.страница
// если были на слайде алгоритма, переходим сразу на 14й слайд (параметры ИК)
if((ix>=1 && ix<=11))
sw->setCurrentIndex(12);
else
sw->setCurrentIndex( (ix<(sw->count()-1))? ix+1 : 0);
}
else if(key == Qt::Key_Left) {// предыд.страница
// если были на слайде алгоритма, переходим на 1й слайд
if(ix>=1 && ix<=11)
sw->setCurrentIndex(0);
else if(ix==12) // если были на таблице ИК, на первый слайд с алгоритмами
sw->setCurrentIndex(1);
else
sw->setCurrentIndex(ix > 0? ix-1 : sw->count()-1);
}
else if(key == Qt::Key_Down) { // след.слайд в группе слайдов
if(ix==12) { // если мы на таблице ППН
ui->sw2->setCurrentIndex(( ui->sw2->currentIndex() <ui->sw2->count()-1 )? ui->sw2->currentIndex() + 1 : 0);
}
else if(ix>=1 && ix<=11) { // если на алгоритмах защит
sw->setCurrentIndex( (ix<11)? ix+1 : 1);
}
else if(ix==13) { // слайд дискр сигналов
discrSlideCurr<3?discrSlideCurr++:discrSlideCurr=0;
// switch(discrSlideCurr) {
// case 0: // вх 151,152
// paintEvent1(in151);
// break;
// case 1:
// paintEvent1(out155az);
// break;
// case 2:
// paintEvent1(out155pz);
// break;
// case 3:
// paintEvent1(pca);
// break;
// }
update();
}
}
else if(key == Qt::Key_Up) { // предыд.страница
if(ix==12) { // если мы на таблице ППН
ui->sw2->setCurrentIndex((ui->sw2->currentIndex() > 0 )? ui->sw2->currentIndex()-1 : ui->sw2->count()-1);
}
else if(ix>=1 && ix<=11) { // если на алгоритмах защит
sw->setCurrentIndex( (ix>1)? ix-1 : 11);
}
else if(ix==13) { // слайд дискр сигналов
discrSlideCurr>0?discrSlideCurr--:discrSlideCurr=3;
update();
}
//.........这里部分代码省略.........
示例6: updateCLI
// Update associated CLI widget based on QWidget / QObject data
void QtWidgetObject::updateCLI()
{
// Check treeGuiWidget_ pointer first
if (treeGuiWidget_ == NULL)
{
printf("Internal Error: treeGuiWidget_ pointer is NULL in updateCLI().\n");
return;
}
// Now, check widget type to see what we do
if (treeGuiWidget_->type() == TreeGuiWidget::RadioGroupWidget)
{
QButtonGroup *butgroup = static_cast<QButtonGroup*>(qObject_);
if (!butgroup) printf("Critical Error: Couldn't cast stored qObject_ pointer into QButtonGroup.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, butgroup->checkedId());
}
else if (treeGuiWidget_->type() == TreeGuiWidget::CheckWidget)
{
QCheckBox *check = static_cast<QCheckBox*>(qWidget_);
if (!check) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QCheckBox.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, check->isChecked());
}
else if (treeGuiWidget_->type() == TreeGuiWidget::ComboWidget)
{
QComboBox* combo = static_cast<QComboBox*>(qWidget_);
if (!combo) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QComboBox.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, combo->currentIndex()+1);
}
else if (treeGuiWidget_->type() == TreeGuiWidget::DoubleSpinWidget)
{
QDoubleSpinBox* spin = static_cast<QDoubleSpinBox*>(qWidget_);
if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QDoubleSpinBox.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, spin->value());
}
else if (treeGuiWidget_->type() == TreeGuiWidget::EditWidget)
{
QLineEdit *edit = static_cast<QLineEdit*>(qWidget_);
if (!edit) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTextEdit.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, qPrintable(edit->text()));
}
else if (treeGuiWidget_->type() == TreeGuiWidget::IntegerSpinWidget)
{
QSpinBox *spin = static_cast<QSpinBox*>(qWidget_);
if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QSpinBox.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, spin->value());
}
else if (treeGuiWidget_->type() == TreeGuiWidget::LabelWidget)
{
QLabel *label = static_cast<QLabel*>(qWidget_);
if (!label) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QLabel.\n");
}
else if (treeGuiWidget_->type() == TreeGuiWidget::RadioButtonWidget)
{
QRadioButton *button = static_cast<QRadioButton*>(qWidget_);
if (!button) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QRadioButton.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, button->isChecked());
}
else if (treeGuiWidget_->type() == TreeGuiWidget::TabWidget)
{
QTabWidget *tabs = static_cast<QTabWidget*>(qWidget_);
if (!tabs) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTabWidget.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, tabs->currentIndex()+1);
}
else if (treeGuiWidget_->type() == TreeGuiWidget::StackWidget)
{
QStackedWidget *stack = static_cast<QStackedWidget*>(qWidget_);
if (!stack) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QStackedWidget.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, stack->currentIndex()+1);
}
else printf("Internal Error: No handler written to update CLI controls of this type (%s).\n", TreeGuiWidget::widgetType(treeGuiWidget_->type()));
}