本文整理汇总了C++中QStackedWidget::addWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ QStackedWidget::addWidget方法的具体用法?C++ QStackedWidget::addWidget怎么用?C++ QStackedWidget::addWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStackedWidget
的用法示例。
在下文中一共展示了QStackedWidget::addWidget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setWindowTitle
MainWindow::MainWindow(QWidget *parent, QFlag flags) :
QMainWindow(parent, flags)
{
// Set window title
setWindowTitle("3D Computergrafik I - SS2015 - Aufgabenblatt 4");
// Create main container
QWidget *container = new QWidget();
setCentralWidget(container);
// Add list (on the left)
QListWidget *list = new QListWidget(container);
list->addItem("Aufgabe 12");
list->addItem("Aufgabe 13");
list->addItem("Aufgabe 14");
list->setMaximumWidth(150);
// Add stack of exercise windows (on the right)
QStackedWidget *stack = new QStackedWidget(container);
// Add exercises to widget
stack->addWidget(new GLViewer(new Exercise12()));
stack->addWidget(new GLViewer(new Exercise13()));
stack->addWidget(new GLViewer(new Exercise14()));
// Create layout
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(list);
layout->addWidget(stack);
container->setLayout(layout);
// Connect selection-event of list to select the current visible window
connect(list, SIGNAL(currentRowChanged(int)), stack, SLOT(setCurrentIndex(int)));
}
示例3: QDialog
Dialog::Dialog( QWidget *parent ) : QDialog( parent )
{
//ui.setupUi( this );
QLabel *Label1 = new QLabel( tr( "Label1" ) );
QLabel *Label2 = new QLabel( tr( "Label2" ) );
QLabel *Label3 = new QLabel( tr( "Label3" ) );
QListWidget *list = new QListWidget( this );
list->insertItem( 0, tr( "Window1" ) );
list->insertItem( 1, tr( "Window2" ) );
list->insertItem( 2, tr( "Window3" ) );
QStackedWidget *stack = new QStackedWidget( this );
stack->addWidget( Label1 );
stack->addWidget( Label2 );
stack->addWidget( Label3 );
QHBoxLayout *Layout = new QHBoxLayout( this );
Layout->setMargin( 5 );
Layout->setSpacing( 5 );
Layout->addWidget( list );
Layout->addWidget( stack, 0, Qt::AlignHCenter );
Layout->setStretchFactor( list, 1 );
Layout->setStretchFactor( stack, 3 );
connect( list, SIGNAL( currentRowChanged( int ) ), stack, SLOT( setCurrentIndex( int ) ) );
}
示例4: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
std::random_device rd;
random_engine gen(rd());
int imageSize = 300;
QList<QImage> images;
for (int n = 0; n < 28; ++n) images << randomImage(imageSize, gen);
std::uniform_int_distribution<> dImage(0, images.size()-1);
QStackedWidget display;
QPushButton ready("I'm Ready!");
QLabel label, labelHidden;
display.addWidget(&ready);
display.addWidget(&label);
display.addWidget(&labelHidden);
QTimer splashTimer;
QStateMachine machine;
QState s1(&machine), s2(&machine), s3(&machine), s4(&machine);
splashTimer.setSingleShot(true);
QObject::connect(&s1, &QState::entered, [&]{
display.setCurrentWidget(&ready);
ready.setDefault(true);
ready.setFocus();
});
s1.addTransition(&ready, "clicked()", &s2);
QObject::connect(&s2, &QState::entered, [&]{
label.setPixmap(QPixmap::fromImage(images.at(dImage(gen))));
display.setCurrentWidget(&label);
splashTimer.start(250 + std::uniform_int_distribution<>(1500, 3000)(gen));
});
s2.addTransition(&splashTimer, "timeout()", &s3);
QObject::connect(&s3, &QState::entered, [&]{
display.setCurrentWidget(&labelHidden);
splashTimer.start(2000);
});
s3.addTransition(&splashTimer, "timeout()", &s4);
QObject::connect(&s4, &QState::entered, [&]{
display.setCurrentWidget(&label);
splashTimer.start(3000);
});
s4.addTransition(&splashTimer, "timeout()", &s1);
machine.setInitialState(&s1);
machine.start();
display.show();
return a.exec();
}
示例5: main
int main( int argc, char *argv[] )
{
QApplication a( argc, argv );
QMainWindow mainWindow;
HGRSVM svm = HGRSVM();
svm.train( 100 );
QStackedWidget *stackedWidget = new QStackedWidget;
MyMainWindow *myMainWindow = new MyMainWindow( stackedWidget );
stackedWidget->addWidget( myMainWindow );
stackedWidget->setCurrentWidget( myMainWindow );
mainWindow.setCentralWidget(stackedWidget);
mainWindow.setWindowTitle( "Hand gesture recognition for ArDrone" );
mainWindow.resize(950, 500);
mainWindow.show();
thread th1( runArdrone );
int status = a.exec();
order = 1;
th1.join();
return status;
}
示例6: dynamicPages
void tst_QStackedWidget::dynamicPages()
{
QStackedWidget *sw = new QStackedWidget;
TestPage *w1 = new TestPage(true);
w1->setN(3);
TestPage *w2 = new TestPage;
w2->setN(3);
sw->addWidget(w1);
sw->addWidget(w2);
QLineEdit *le11 = w1->findChild<QLineEdit*>(QLatin1String("lineEdit1"));
le11->setFocus(); // set focus to second widget in the page
sw->resize(200, 200);
sw->show();
qApp->setActiveWindow(sw);
QTest::qWaitForWindowActive(sw);
QTRY_COMPARE(QApplication::focusWidget(), le11);
sw->setCurrentIndex(1);
QLineEdit *le22 = w2->findChild<QLineEdit*>(QLatin1String("lineEdit2"));
le22->setFocus();
QTRY_COMPARE(QApplication::focusWidget(), le22);
// Going back should move focus back to le11
sw->setCurrentIndex(0);
QTRY_COMPARE(QApplication::focusWidget(), le11);
}
示例7: addWidget
int QStackedWidgetProto::addWidget(QWidget *widget)
{
QStackedWidget *item = qscriptvalue_cast<QStackedWidget*>(thisObject());
if (item)
return item->addWidget(widget);
return -1;
}
示例8: if
void
InsertPageCommand::execute()
{
KFormDesigner::Container *container = m_form->objectTree()->lookup(m_containername)->container();
QWidget *parent = m_form->objectTree()->lookup(m_parentname)->widget();
if (m_name.isEmpty()) {
m_name = container->form()->objectTree()->generateUniqueName(
container->form()->library()->displayName("QWidget").toLatin1(),
/*!numberSuffixRequired*/false);
}
QWidget *page = container->form()->library()->createWidget(
"QWidget", parent, m_name.toLatin1(), container);
page->setAutoFillBackground(true);
// page->setPaletteBackgroundColor(Qt::red);
KFormDesigner::ObjectTreeItem *item = container->form()->objectTree()->lookup(m_name);
QByteArray classname = parent->metaObject()->className();
if (classname == "KFDTabWidget") {
TabWidgetBase *tab = dynamic_cast<TabWidgetBase*>(parent);
QString n = i18n("Page %1", tab->count() + 1);
tab->addTab(page, n);
tab->setCurrentWidget(page);
item->addModifiedProperty("title", n);
} else if (classname == "QStackedWidget" || /* compat */ classname == "QWidgetStack") {
QStackedWidget *stack = dynamic_cast<QStackedWidget*>(parent);
stack->addWidget(page);
stack->setCurrentWidget(page);
item->addModifiedProperty("stackIndex", stack->indexOf(page));
}
}
示例9: getCellImp
void SplitGrid2::setCell(QWidget * w, int row, int col)
{
Q_ASSERT( w != 0 );
QStackedWidget* cell = getCellImp( row, col );
Q_ASSERT( cell != 0 );
if( cell->count() > 0 )
cell->removeWidget( cell->widget(0) );
cell->addWidget( w );
}
示例10: customSettings
QT_BEGIN_NAMESPACE
FontSettingsDialog::FontSettingsDialog(QWidget *parent)
: QDialog(parent)
, m_windowFontPanel(new FontPanel(this))
, m_browserFontPanel(new FontPanel(this))
, m_dialogButtonBox(new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel))
{
setModal(true);
setWindowTitle(tr("Font Settings"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QVBoxLayout *mainVLayout = new QVBoxLayout(this);
QHBoxLayout *hboxLayout = new QHBoxLayout;
mainVLayout->addLayout(hboxLayout);
QLabel *label = new QLabel(tr("Font settings for:"), this);
label->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
hboxLayout->addWidget(label);
QComboBox *comboBox = new QComboBox(this);
comboBox->addItem(tr("Browser"));
comboBox->addItem(tr("Application"));
hboxLayout->addWidget(comboBox);
m_windowFontPanel->setCheckable(true);
m_browserFontPanel->setCheckable(true);
const QString customSettings(tr("Use custom settings"));
m_windowFontPanel->setTitle(customSettings);
m_browserFontPanel->setTitle(customSettings);
QStackedWidget *stackWidget = new QStackedWidget(this);
stackWidget->addWidget(m_browserFontPanel);
stackWidget->addWidget(m_windowFontPanel);
mainVLayout->addWidget(stackWidget);
mainVLayout->addWidget(m_dialogButtonBox);
connect(m_dialogButtonBox , SIGNAL(rejected()), this, SLOT(reject()));
connect(m_dialogButtonBox , SIGNAL(accepted()), this, SLOT(accept()));
connect(comboBox, SIGNAL(activated(int)), stackWidget, SLOT(setCurrentIndex(int)));
}
示例11: QPushButton
QWidget *UserBindsPage::widget()
{
unsigned p, retro_id;
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
QWidget *widget = new QWidget;
QGridLayout *layout = new QGridLayout;
QComboBox *userCombo = new QComboBox;
QStackedWidget *stack = new QStackedWidget;
for (p = 0; p < max_users; p++)
{
userCombo->addItem(QString::number(p));
QWidget *uWidget = new QWidget();
FormLayout *form = new FormLayout();
for (retro_id = 0; retro_id < RARCH_FIRST_CUSTOM_BIND + 20; retro_id++)
{
char descriptor[300];
const struct retro_keybind *keybind =
&input_config_binds[p][retro_id];
const struct retro_keybind *auto_bind =
(const struct retro_keybind*)
input_config_get_bind_auto(p, retro_id);
input_config_get_bind_string(descriptor,
keybind, auto_bind, sizeof(descriptor));
const struct retro_keybind *keyptr =
&input_config_binds[p][retro_id];
QString label = msg_hash_to_str(keyptr->enum_idx);
form->addRow(QString(msg_hash_to_str(keyptr->enum_idx)),
new QPushButton(QString(descriptor)));
}
uWidget->setLayout(form);
stack->addWidget(uWidget);
}
connect(userCombo, SIGNAL(activated(int)),
stack, SLOT(setCurrentIndex(int)));
layout->addWidget(userCombo, 0, 0);
layout->addWidget(stack, 1, 0);
widget->setLayout(layout);
return widget;
}
示例12: main
int main(int argc,char **argv)
{
QApplication app(argc,argv);
QCoreApplication::setOrganizationName("Rabitsa");
QCoreApplication::setApplicationName("filters");
QApplication::setStyle(new QPlastiqueStyle);
QSettings s;
IoNetClient net( s.value("/ioserv/hostname","localhost").toString());
net.setCmode(
#ifdef WIN32
false
#else
s.value("/ioserv/cmode",true).toBool()
#endif
);
QStackedWidget main;
QColor cl;
QPalette pal;
cl.setRgb(90,132,201);
pal.setColor(QPalette::Background,cl);
main.setPalette(pal);
QTranslator translator;
translator.load("filters_"+QLocale::system().name(),":/translate");
app.installTranslator(&translator);
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
mMainForm *mainForm = new mMainForm(net);
main.addWidget(mainForm);
main.setCurrentWidget(mainForm);
if(QApplication::desktop()->size().width()>1366 && QApplication::desktop()->size().height()> 768)
{
main.resize(1366,768);
main.show();
}
else
{
main.showFullScreen();
}
return app.exec();
}
示例13: addPage
// Create new page (only in Tab widget or Stack widget)
QtWidgetObject* AtenTreeGuiDialog::addPage(TreeGuiWidget* widget, TreeGuiWidget* parentWidget, QString label)
{
// Grab widget object...
QtWidgetObject* wo = parentWidget->qtWidgetObject();
if (wo == NULL)
{
printf("Internal Error: Can't add page to tabwidget since supplied tabwidget doesn't have an associated QtWidgetObject.\n");
return NULL;
}
// Create new page widget and layout
QWidget* pageWidget = new QWidget(this);
QGridLayout *layout = addLayout(pageWidget);
// Create widget object to return
QtWidgetObject* qtwo = widgetObjects_.add();
qtwo->set(widget, pageWidget, NULL, layout);
pageWidget->setEnabled(widget->enabled());
pageWidget->setVisible(widget->visible());
pageWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// Cast parent widget into correct type, and add page
if (parentWidget->type() == TreeGuiWidget::TabWidget)
{
// Cast QWidget in parentWidget into QTabWidget
QTabWidget *tabs = static_cast<QTabWidget*>(wo->qWidget());
if (!tabs)
{
printf("Internal Error: Couldn't cast QWidget into QTabWidget.\n");
return NULL;
}
int id = tabs->addTab(pageWidget, label);
}
else if (parentWidget->type() == TreeGuiWidget::StackWidget)
{
// Cast QWidget in parentWidget into QStackedWidget
QStackedWidget *stack = static_cast<QStackedWidget*>(wo->qWidget());
if (!stack)
{
printf("Internal Error: Couldn't cast QWidget into QStackedWidget.\n");
return NULL;
}
int id = stack->addWidget(pageWidget);
}
else printf("Internal Error: Tried to add a page into a widget type (%s) that doesn't support it.\n", TreeGuiWidget::widgetType(widget->type()));
return qtwo;
}
示例14: visitAdvancedList
void PropertyWidgetBuilder::visitAdvancedList(AdvancedListProperty & property)
{
QComboBox * comboBox = new QComboBox(m_active_widget);
comboBox->addItems(property.choices());
m_active_layout->addRow(property.description(), comboBox);
QStackedWidget * groupBoxesStack = new QStackedWidget(m_active_widget);
m_active_layout->addRow(groupBoxesStack);
for (PropertyList * propertyList : property.propertyLists()) {
QGroupBox * groupBox = new QGroupBox(m_active_widget);
groupBox->setAlignment(Qt::AlignVCenter);
QFormLayout * groupboxlayout = new QFormLayout(groupBox);
if (propertyList->isEmpty()) {
QLabel * label = new QLabel("No Properties to display", groupBox);
label->setAlignment(Qt::AlignCenter);
groupboxlayout->addWidget(label);
}
QWidget * former_active_widget = m_active_widget;
QFormLayout * former_active_layout = m_active_layout;
m_active_widget = groupBox;
m_active_layout = groupboxlayout;
this->iterateOverProperties(propertyList->list());
m_active_widget = former_active_widget;
m_active_layout = former_active_layout;
groupBoxesStack->addWidget(groupBox);
}
QObject::connect(comboBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
[&property, groupBoxesStack] (const QString & text) {
property.select(text);
groupBoxesStack->setCurrentIndex(property.selection());
qDebug("Set Property %s = \"%s\"",
qPrintable(property.name()),
qPrintable(property.selectedChoice()));
}
);
}
示例15: startMasterPageMode
void PagePalette::startMasterPageMode(QString masterPage)
{
ScribusDoc* doc = m_view->Doc;
bool mustDeselect = false;
mustDeselect |= (!doc->masterPageMode());
mustDeselect |= (doc->masterPageMode() && doc->currentPage()->pageName() != masterPage);
if (mustDeselect)
{
// We must avoid deselecting directly if doc is in an edit mode,
// otherwise that would cause an inconsistent state. In such case,
// fallback to normal mode by precaution
if (doc->appMode != modeNormal)
m_view->requestMode(modeNormal);
m_view->Deselect(true);
}
QStackedWidget* stackedWidget = this->stackedWidget();
if (stackedWidget->count() < 2)
{
PagePalette_MasterPages* mpWidget = new PagePalette_MasterPages(stackedWidget, m_view, masterPage);
mpWidget->setObjectName(QString::fromLocal8Bit("PagePalette_MasterPages"));
stackedWidget->addWidget(mpWidget);
connect(mpWidget, SIGNAL(removePage(int )), m_scMW, SLOT(deletePage2(int )));
connect(mpWidget, SIGNAL(finished()) , m_scMW, SLOT(editMasterPagesEnd()));
}
else
{
ScribusDoc* doc = m_view->Doc;
PagePalette_MasterPages* mpWidget = this->masterpageWidget();
if (mpWidget->m_view != m_view)
mpWidget->setView(m_view, masterPage);
mpWidget->updateMasterPageList(masterPage);
if (doc->currentPage()->pageName() != masterPage)
mpWidget->selectMasterPage(masterPage);
}
// Set focus to page palette or focus may be set to wrong document window
this->setFocus();
stackedWidget->setCurrentIndex(1);
}