本文整理汇总了C++中QBoxLayout::addItem方法的典型用法代码示例。如果您正苦于以下问题:C++ QBoxLayout::addItem方法的具体用法?C++ QBoxLayout::addItem怎么用?C++ QBoxLayout::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBoxLayout
的用法示例。
在下文中一共展示了QBoxLayout::addItem方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KDialog
StatusDialog::StatusDialog( QWidget *parent )
: KDialog( parent )
{
setModal( true );
setCaption( i18n( "Set Your Status" ) );
QBoxLayout *topLayout = new QVBoxLayout( this );
topLayout->setSpacing( spacingHint() );
topLayout->setMargin( marginHint() );
QBoxLayout *statusLayout = new QHBoxLayout();
topLayout->addItem( statusLayout );
QLabel *text = new QLabel( i18n( "Set your status" ), this );
statusLayout->addWidget( text );
mStatus = new KComboBox( this );
mStatus->setEditable( false );
mStatus->addItems( Attendee::statusList() );
statusLayout->addWidget( mStatus );
QBoxLayout *buttonLayout = new QHBoxLayout();
topLayout->addItem( buttonLayout );
QPushButton *ok = new KPushButton( KStandardGuiItem::ok(), this );
connect ( ok, SIGNAL(clicked()), this, SLOT(accept()) );
buttonLayout->addWidget( ok );
QPushButton *cancel = new KPushButton( KStandardGuiItem::cancel(), this );
connect ( cancel, SIGNAL(clicked()), this, SLOT(reject()) );
buttonLayout->addWidget( cancel );
}
示例2: setVertical
void MiniProgrammerUI::setVertical(bool vertical)
{
if(m_isVertical == vertical)
return;
m_isVertical = vertical;
QBoxLayout *from = ui->horLayout;
QBoxLayout *to = ui->vertLayout;
if(!vertical)
std::swap(from, to);
while(from->count() != 0)
{
QLayoutItem *i = from->takeAt(0);
if(i->layout())
{
i->layout()->setParent(0);
to->addLayout(i->layout());
}
else
to->addItem(i);
}
delete to->takeAt(to->count()-1);
to->addStretch(1);
}
示例3: QDialog
WaitDialog::WaitDialog(QWidget* parent)
: QDialog(parent),
d(new Private(this))
{
// Create the UI
this->setObjectName("qttools__WaitDialog");
this->setWindowTitle(tr("Waiting"));
this->resize(170, 60);
d->m_waitLabel = new QLabel(this);
d->m_btnBox = new QDialogButtonBox(this);
d->m_btnBox->setStandardButtons(QDialogButtonBox::Abort);
d->m_progressBar = new QProgressBar(this);
d->m_progressBar->setValue(0);
d->m_progressBar->setTextVisible(false);
QBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(d->m_waitLabel);
layout->addWidget(d->m_progressBar);
layout->addWidget(d->m_btnBox);
layout->addItem(new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
// Configure
this->setWindowModality(Qt::ApplicationModal);
connect(d->m_updateTimer, SIGNAL(timeout()), this, SLOT(updateProgress()));
d->m_updateTimer->setInterval(500);
}
示例4: QFrame
//============================================================================
//
// class SingleConditionWidget (editor for one condition, used in ConditionEditWidget)
//
//============================================================================
SingleConditionWidget::SingleConditionWidget( KScoringManager *m, QWidget *p, const char * )
: QFrame( p ), manager( m )
{
QBoxLayout *topL = new QVBoxLayout( this );
topL->setMargin( 5 );
QBoxLayout *firstRow = new QHBoxLayout();
topL->addItem( firstRow );
neg = new QCheckBox( i18n( "Not" ), this );
neg->setToolTip( i18n( "Negate this condition" ) );
firstRow->addWidget( neg );
headers = new KComboBox( this );
headers->addItems( manager->getDefaultHeaders() );
headers->setEditable( true );
headers->setToolTip( i18n( "Select the header to match this condition against" ) );
firstRow->addWidget( headers, 1 );
matches = new KComboBox( this );
matches->addItems( KScoringExpression::conditionNames() );
matches->setToolTip( i18n( "Select the type of match" ) );
firstRow->addWidget( matches, 1 );
connect( matches, SIGNAL( activated( int ) ), SLOT( toggleRegExpButton( int ) ) );
QHBoxLayout *secondRow = new QHBoxLayout();
secondRow->setSpacing( 1 );
topL->addItem( secondRow );
expr = new KLineEdit( this );
expr->setToolTip( i18n( "The condition for the match" ) );
// reserve space for at least 20 characters
expr->setMinimumWidth( fontMetrics().maxWidth() * 20 );
secondRow->addWidget( expr );
regExpButton = new QPushButton( i18n( "Edit..." ), this );
secondRow->addWidget( regExpButton );
connect( regExpButton, SIGNAL( clicked() ), SLOT( showRegExpDialog() ) );
regExpButton->setEnabled(!KServiceTypeTrader::self()->query( "KRegExpEditor/KRegExpEditor" ).isEmpty());
// occupy at much width as possible
setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
setFrameStyle( Box | Sunken );
setLineWidth( 1 );
}
示例5: QHBoxLayout
Pana::CrashHandlerWidget::CrashHandlerWidget()
{
QBoxLayout *layout = new QHBoxLayout( this, 18, 12 );
{
QBoxLayout *lay = new QVBoxLayout( layout );
QLabel *label = new QLabel( this );
label->setPixmap( locate( "data", "drkonqi/pics/konqi.png" ) );
label->setFrameStyle( QFrame::Plain | QFrame::Box );
lay->add( label );
lay->addItem( new QSpacerItem( 3, 3, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
}
layout = new QVBoxLayout( layout, 6 );
layout->add( new QLabel( /*i18n*/(
"<p>" "Pana has crashed! We are terribly sorry about this :("
"<p>" "However you now have an opportunity to help us fix this crash so that it doesn't "
"happen again! Click <b>Send Email</b> and Pana will prepare an email that you "
"can send to us that contains information about the crash, and we'll try to fix it "
"as soon as possible."
"<p>" "Thanks for choosing Pana.<br>" ), this ) );
layout = new QHBoxLayout( layout, 6 );
layout->addItem( new QSpacerItem( 6, 6, QSizePolicy::Expanding ) );
layout->add( new KPushButton( KGuiItem( i18n("Send Email"), "mail_send" ), this, "email" ) );
layout->add( new KPushButton( KStdGuiItem::close(), this, "close" ) );
static_cast<QPushButton*>(child("email"))->setDefault( true );
connect( child( "email" ), SIGNAL(clicked()), SLOT(accept()) );
connect( child( "close" ), SIGNAL(clicked()), SLOT(reject()) );
setCaption( i18n("Crash Handler") );
setFixedSize( sizeHint() );
}
示例6: KXmlGuiWindow
TopWidget::TopWidget() : KXmlGuiWindow(0) {
// Check command line args for "-kppp"
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
bool kpppmode = args->isSet("kppp");
args->clear();
setCaption(i18n("KPPP Log Viewer"));
w = new QWidget(this);
QBoxLayout *l = new QVBoxLayout(w);
l->setSpacing(5);
td = new QTabWidget(w);
mw = new MonthlyWidget();
td->addTab(mw, i18n("Monthly Log"));
// remove buttons
if(!kpppmode) {
// create menu
mb = new KMenuBar;
l->addWidget(mb);
l->addWidget(td);
QMenu *fm = new QMenu;
QAction *action = fm->addAction(QIcon(SmallIcon("application-exit")), KStandardGuiItem::quit().text());
action->setShortcut(Qt::CTRL + Qt::Key_Q);
connect(action,SIGNAL(triggered()), this, SLOT(slotExit()));
fm->setTitle(i18n("&File"));
mb->addMenu(fm);
} else {
l->addWidget(td);
mb = 0;
QPushButton *but = new KPushButton(KStandardGuiItem::close(),w);
QHBoxLayout *lh = new QHBoxLayout();
l->addItem(lh);
lh->addStretch(10);
lh->addWidget(but);
connect(but, SIGNAL(clicked()),
kapp, SLOT(quit()));
}
setMinimumSize(mw->sizeHint().width() + 15,
mw->sizeHint().height() + 120);
setCentralWidget(w);
}
示例7: KDialog
DistributionListDialog::DistributionListDialog( QWidget *parent )
: KDialog( parent )
{
QFrame *topFrame = new QFrame( this );
setMainWidget( topFrame );
setCaption( i18nc("@title:window", "Save Distribution List") );
setButtons( User1 | Cancel );
setDefaultButton( User1 );
setModal( false );
setButtonText( User1, i18nc("@action:button","Save List") );
enableButton( User1, false );
QBoxLayout *topLayout = new QVBoxLayout( topFrame );
topLayout->setSpacing( spacingHint() );
QBoxLayout *titleLayout = new QHBoxLayout();
titleLayout->setSpacing( spacingHint() );
topLayout->addItem( titleLayout );
QLabel *label = new QLabel(
i18nc("@label:textbox Name of the distribution list.", "&Name:"), topFrame );
titleLayout->addWidget( label );
mTitleEdit = new KLineEdit( topFrame );
titleLayout->addWidget( mTitleEdit );
mTitleEdit->setFocus();
mTitleEdit->setClearButtonShown( true );
label->setBuddy( mTitleEdit );
mRecipientsList = new QTreeWidget( topFrame );
mRecipientsList->setHeaderLabels(
QStringList() << i18nc( "@title:column Name of the recipient","Name" )
<< i18nc( "@title:column Email of the recipient", "Email" )
);
mRecipientsList->setRootIsDecorated( false );
topLayout->addWidget( mRecipientsList );
connect( this, SIGNAL( user1Clicked() ),
this, SLOT( slotUser1() ) );
connect( mTitleEdit, SIGNAL( textChanged( const QString& ) ),
this, SLOT( slotTitleChanged( const QString& ) ) );
}
示例8: QWidget
FilterWidget::FilterWidget(TQueryMap opts, QList<Attr*> list, Keeper *keeper, QWidget *parent) :
QWidget(parent), keeper(keeper), attrList(list), parentWidget(parent), opts(opts)
{
innerWidget = new QWidget(this);
scrollArea = new QScrollArea(this);
scrollArea->setWidget( innerWidget );
scrollArea->setWidgetResizable( true );
innerLayout = new QGridLayout( innerWidget );
innerLayout->setSpacing(2);
innerLayout->setMargin(2);
QWidget *w = 0;
int row = 0;
for( int i = 0; i < attrList.size(); i++ )
{
QApplication::processEvents();
Attr *a = list.at(i);
w = getAttrWidget( a, innerWidget );
if ( !w ) continue;
QCheckBox *box = new QCheckBox( a->getTitle(), innerWidget);
if ( opts.contains(a->getName()) ) {
box->setChecked(true);
setWidgetData(a, w, opts[a->getName()]);
} else {
w->setEnabled(false);
}
widgetMap.insert( a->getName(), w );
connect(box, SIGNAL(toggled(bool)), w, SLOT(setEnabled(bool)));
innerLayout->addWidget( box, row++, 0 );
innerLayout->addWidget( w, row++, 0);
}
filterButton = new QPushButton(tr("Filter"), innerWidget);
filterButton->setIcon(QIcon(":/icons/magnifier.png"));
clearButton = new QPushButton(tr("Clear"), innerWidget);
clearButton->setIcon(QIcon(":/icons/cancel.png"));
connect(filterButton, SIGNAL(clicked()), this, SLOT(filterButton_clicked()));
connect(clearButton, SIGNAL(clicked()), this, SLOT(clearButton_clicked()));
QBoxLayout *hlayout = new QBoxLayout(QBoxLayout::LeftToRight);
hlayout->addWidget(filterButton);
hlayout->addWidget(clearButton);
hlayout->addItem(new QSpacerItem(10, 10 ));
innerLayout->addLayout(hlayout, row++, 0);
innerLayout->addItem( new QSpacerItem(20, 1200, QSizePolicy::Maximum, QSizePolicy::Maximum), row, 0);
QGridLayout *glayout = new QGridLayout(this);
glayout->addWidget(scrollArea, 0, 0);
glayout->setSpacing(2);
glayout->setMargin(2);
setLayout(glayout);
}
示例9: fm
InterfacePlotterDialog::InterfacePlotterDialog( QString name )
: KDialog(),
mConfig( KGlobal::config() ),
mConfigDlg( 0 ),
mLabelsWidget( NULL ),
mSetPos( true ),
mWasShown( false ),
mUseBitrate( generalSettings->useBitrate ),
mMultiplier( 1024 ),
mOutgoingVisible( false ),
mIncomingVisible( false ),
mName( name )
{
setCaption( i18nc( "interface name", "%1 Traffic", mName ) );
setButtons( None );
setContextMenuPolicy( Qt::DefaultContextMenu );
mByteUnits << ki18n( "%1 B/s" ) << ki18n( "%1 KiB/s" ) << ki18n( "%1 MiB/s" ) << ki18n( "%1 GiB/s" );
mBitUnits << ki18n( "%1 bit/s" ) << ki18n( "%1 kbit/s" ) << ki18n( "%1 Mbit/s" ) << ki18n( "%1 Gbit/s" );
mIndicatorSymbol = '#';
QFontMetrics fm(font());
if (fm.inFont(QChar(0x25CF)))
mIndicatorSymbol = QChar(0x25CF);
QBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
mainWidget()->setLayout( layout );
mPlotter = new KSignalPlotter( this );
int axisTextWidth = fontMetrics().width(i18nc("Largest axis title", "99999 XXXX"));
mPlotter->setMaxAxisTextWidth( axisTextWidth );
mPlotter->setShowAxis( true );
mPlotter->setUseAutoRange( true );
layout->addWidget(mPlotter);
/* Create a set of labels underneath the graph. */
mLabelsWidget = new QWidget;
layout->addWidget(mLabelsWidget);
QBoxLayout *outerLabelLayout = new QHBoxLayout(mLabelsWidget);
outerLabelLayout->setSpacing(0);
outerLabelLayout->setContentsMargins(0,0,0,0);
/* create a spacer to fill up the space up to the start of the graph */
outerLabelLayout->addItem(new QSpacerItem(axisTextWidth + 10, 0, QSizePolicy::Preferred));
mLabelLayout = new QHBoxLayout;
outerLabelLayout->addLayout(mLabelLayout);
mReceivedLabel = new FancyPlotterLabel( this );
mSentLabel = new FancyPlotterLabel( this );
mLabelLayout->addWidget( mSentLabel );
mLabelLayout->addWidget( mReceivedLabel );
// Restore window size and position.
KConfig *config = mConfig.data();
KConfigGroup interfaceGroup( config, confg_interface + mName );
if ( interfaceGroup.hasKey( conf_plotterPos ) )
{
QPoint p = interfaceGroup.readEntry( conf_plotterPos, QPoint() );
// See comment in event()
mSetPos = false;
move( p );
}
if ( interfaceGroup.hasKey( conf_plotterSize ) )
{
QSize s = interfaceGroup.readEntry( conf_plotterSize, QSize() );
// A little hack so the plotter's data isn't chopped off the first time
// the dialog appears
mPlotter->resize( s );
resize( s );
}
else
{
// HACK
mPlotter->resize( 500, 350 );
// Improve the chance that we have a decent sized dialog
// the first time it's shown
resize( 500, 350 );
}
connect( mPlotter, SIGNAL(axisScaleChanged()), this, SLOT(setPlotterUnits()) );
loadConfig();
}
示例10: clicked
//.........这里部分代码省略.........
#endif
for (it = rowSet.rbegin(); it != rowSet.rend(); ++it)
{
mComponentSelection->selectedComponentsView()->model()->removeRow(*it);
}
}
ComponentSelection * mComponentSelection;
};
class PrivateSubscriberClose
: public QObject
, private SubscribablePushButton::Subscriber
{
public:
~PrivateSubscriberClose()
{
}
PrivateSubscriberClose(SubscribablePushButton * pushButton, ComponentSelection * componentSelection)
: QObject(pushButton)
, SubscribablePushButton::Subscriber(pushButton)
, mComponentSelection(componentSelection)
{
}
private:
void clicked(bool checked)
{
if (mComponentSelection->shipConfig() != NULL)
{
mComponentSelection->shipConfig()->setComponents(mComponentSelection->selectedComponents());
}
MainWindow::instance().showFrame(MainWindow::ShipDesignIndex);
}
ComponentSelection * mComponentSelection;
};
QBoxLayout * topLayout = new QVBoxLayout();
setLayout(topLayout);
topLayout->setContentsMargins(0,0,0,0);
QBoxLayout * tableLayout = new QHBoxLayout();
topLayout->addItem(tableLayout);
mEditView = new TableView(this);
mEditView->setModel(new ComponentModel(mEditView, NULL));
mEditView->setSelectionBehavior(QAbstractItemView::SelectRows);
mEditView->setSelectionMode(QAbstractItemView::MultiSelection);
mEditView->viewport()->setAcceptDrops(true);
mEditView->setDropIndicatorShown(true);
mEditView->setDragDropMode(QAbstractItemView::NoDragDrop);
mEditView->hideColumn(1);
mEditView->resizeColumnsToContents();
mEditView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
mEditView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
tableLayout->addWidget(mEditView);
(new QsKineticScroller(mEditView))->enableKineticScrollFor(mEditView);
QVBoxLayout * copyButtonsLayout = new QVBoxLayout();
copyButtonsLayout->addStretch();
SubscribablePushButton * addButton = new SubscribablePushButton(this, tr("<<"));
addButton->setObjectName("addButton");
new PrivateSubscriberAdd(addButton, this);
copyButtonsLayout->addWidget(addButton);
SubscribablePushButton * removeButton = new SubscribablePushButton(this, tr(">>"));
removeButton->setObjectName("removeButton");
new PrivateSubscriberRemove(removeButton, this);
copyButtonsLayout->addWidget(removeButton);
copyButtonsLayout->addStretch();
tableLayout->addLayout(copyButtonsLayout);
mListView = new TableView(this);
mListView->setModel(new ComponentModel(mListView, NULL));
mListView->setSelectionBehavior(QAbstractItemView::SelectRows);
mListView->setSelectionMode(QAbstractItemView::MultiSelection);
mListView->setDragEnabled(true);
mListView->setDropIndicatorShown(true);
mListView->setDragDropMode(QAbstractItemView::NoDragDrop);
mListView->resizeColumnsToContents();
mListView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
mListView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
tableLayout->addWidget(mListView);
(new QsKineticScroller(mListView))->enableKineticScrollFor(mListView);
QBoxLayout * buttonLayout = new QHBoxLayout();
topLayout->addItem(buttonLayout);
SubscribablePushButton * closeButton = new SubscribablePushButton(this, tr("Close"));
closeButton->setObjectName("closeButton");
new PrivateSubscriberClose(closeButton, this);
buttonLayout->addStretch();
buttonLayout->addWidget(closeButton);
}
示例11: clicked
HelpPanel::HelpPanel(QWidget * parent)
: QFrame(parent)
{
class PrivateSubscriberClose
: public QObject
, private SubscribablePushButton::Subscriber
{
public:
~PrivateSubscriberClose()
{
}
PrivateSubscriberClose(SubscribablePushButton * pushButton)
: QObject(pushButton)
, SubscribablePushButton::Subscriber(pushButton)
{
}
private:
void clicked(bool checked)
{
MainWindow::instance().showFrame(MainWindow::MainFrameIndex);
}
};
QBoxLayout * topLayout = new QVBoxLayout();
setLayout(topLayout);
QFormLayout * formLayout = new QFormLayout();
QFrame * buttonsWidget = new QFrame(NULL);
buttonsWidget->setLayout(formLayout);
buttonsWidget->setObjectName("helpButtonsWidget");
buttonsWidget->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
SubscribablePushButton * moveShipButton = new SubscribablePushButton(NULL, tr("M"));
moveShipButton->setObjectName("move");
SubscribablePushButton * colonizeButton = new SubscribablePushButton(NULL, tr("C"));
colonizeButton->setObjectName("colonize");
SubscribablePushButton * loadButton = new SubscribablePushButton(NULL, tr("L"));
loadButton->setObjectName("load");
SubscribablePushButton * unloadButton = new SubscribablePushButton(NULL, tr("U"));
unloadButton->setObjectName("unload");
SubscribablePushButton * buildShipButton = new SubscribablePushButton(NULL, tr("B.."));
buildShipButton->setObjectName("build");
SubscribablePushButton * nextTurnButton = new SubscribablePushButton(NULL, tr("T"));
nextTurnButton->setObjectName("turn");
SubscribablePushButton * shipDesignButton = new SubscribablePushButton(NULL, tr("D.."));
shipDesignButton->setObjectName("design");
SubscribablePushButton * researchButton = new SubscribablePushButton(NULL, tr("R.."));
researchButton->setObjectName("research");
SubscribablePushButton * newButton = new SubscribablePushButton(NULL, tr("N.."));
newButton->setObjectName("new");
SubscribablePushButton * openButton = new SubscribablePushButton(NULL, tr("O.."));
openButton->setObjectName("open");
SubscribablePushButton * saveButton = new SubscribablePushButton(NULL, tr("S.."));
saveButton->setObjectName("save");
SubscribablePushButton * quitButton = new SubscribablePushButton(NULL, tr("Q"));
quitButton->setObjectName("quit");
SubscribablePushButton * helpButton = new SubscribablePushButton(NULL, tr("H.."));
helpButton->setObjectName("help");
SubscribablePushButton * setupButton = new SubscribablePushButton(NULL, tr("S.."));
setupButton->setObjectName("setup");
SubscribablePushButton * flagButton = new SubscribablePushButton(NULL, tr("F"));
flagButton->setObjectName("flag");
formLayout->addRow(newButton, new QLabel("Start a new game."));
formLayout->addRow(openButton, new QLabel("Open a saved game."));
formLayout->addRow(saveButton, new QLabel("Save current game."));
formLayout->addRow(quitButton, new QLabel("Quit the program."));
formLayout->addRow(helpButton, new QLabel("This help panel."));
formLayout->addRow(setupButton, new QLabel("Setup panel."));
formLayout->addRow(flagButton, new QLabel("Center map on your home system."));
formLayout->addRow(moveShipButton, new QLabel("Move selected ship."));
formLayout->addRow(loadButton, new QLabel("Load population from planet to selected ship."));
formLayout->addRow(unloadButton, new QLabel("Unload population from selected ship to planet."));
formLayout->addRow(colonizeButton, new QLabel("Order selected ship to colonize planet."));
formLayout->addRow(buildShipButton, new QLabel("Create a build order for an existing ship design."));
formLayout->addRow(shipDesignButton, new QLabel("Create a new ship design."));
formLayout->addRow(researchButton, new QLabel("Research new technologies."));
formLayout->addRow(nextTurnButton, new QLabel("Advance time by one month."));
QScrollArea * scrollArea = new QScrollArea();
scrollArea->setWidget(buttonsWidget);
scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setObjectName("helpButtonsScrollArea");
topLayout->addWidget(scrollArea);
QsKineticScroller * kineticScroller = new QsKineticScroller(scrollArea);
kineticScroller->enableKineticScrollFor(scrollArea);
QBoxLayout * buttonLayout = new QHBoxLayout();
topLayout->addItem(buttonLayout);
SubscribablePushButton * closeButton = new SubscribablePushButton(this, tr("Close"));
closeButton->setObjectName("closeButton");
new PrivateSubscriberClose(closeButton);
//.........这里部分代码省略.........
示例12: clicked
//.........这里部分代码省略.........
{
if (Game::Universe::instance().game().currentPlayer() != NULL && mShipConfigBuild->sector() != NULL)
{
const QModelIndexList & indexList = mShipConfigBuild->selectionModel()->selectedRows();
for (QModelIndexList::const_iterator it = indexList.begin(); it!= indexList.end(); ++it)
{
ShipConfigModel::Row * shipConfig = static_cast<ShipConfigModel::Row *>((*it).internalPointer());
if (shipConfig->count > 0)
{
const_cast<QAbstractItemModel *>(mShipConfigBuild->selectionModel()->model())->setData((*it).sibling((*it).row(), 6), shipConfig->count - 1, Qt::EditRole);
}
}
}
}
ShipConfigBuild * mShipConfigBuild;
};
QBoxLayout * topLayout = new QVBoxLayout();
setLayout(topLayout);
topLayout->setContentsMargins(0,0,0,0);
mEditView = new TableView(this);
//ShipConfigModel * shipConfigModel = new ShipConfigModel(mEditView, NULL);
//mEditView->setModel(shipConfigModel);
mEditView->setSelectionBehavior(QAbstractItemView::SelectRows);
mEditView->setSelectionMode(QAbstractItemView::MultiSelection);
mEditView->setEditTriggers(QAbstractItemView::AllEditTriggers);
mEditView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
mEditView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
topLayout->addWidget(mEditView);
QsKineticScroller * kineticScroller = new QsKineticScroller(mEditView);
kineticScroller->enableKineticScrollFor(mEditView);
QBoxLayout * buttonLayout = new QHBoxLayout();
topLayout->addItem(buttonLayout);
SubscribablePushButton * okButton = new SubscribablePushButton(this, tr("OK"));
okButton->setObjectName("okButton");
new PrivateSubscriberOK(okButton, this);
SubscribablePushButton * cancelButton = new SubscribablePushButton(this, tr("Cancel"));
cancelButton->setObjectName("cancelButton");
new PrivateSubscriberCancel(cancelButton);
SubscribablePushButton * plusButton = new SubscribablePushButton(this, tr("+"));
plusButton->setObjectName("plusButton");
new PrivateSubscriberPlus(plusButton, this);
SubscribablePushButton * minusButton = new SubscribablePushButton(this, tr("-"));
minusButton->setObjectName("minusButton");
new PrivateSubscriberMinus(minusButton, this);
buttonLayout->addStretch();
buttonLayout->addWidget(plusButton);
buttonLayout->addWidget(minusButton);
buttonLayout->addWidget(okButton);
buttonLayout->addWidget(cancelButton);
class SpinBoxDelegate
: public QItemDelegate
{
public:
SpinBoxDelegate(QObject * parent)
: QItemDelegate(parent)
{
}
QWidget *createEditor(QWidget * parent, const QStyleOptionViewItem &, const QModelIndex &) const
{
QSpinBox * editor = new QSpinBox(parent);
editor->setMinimum(0);
editor->setMaximum(100);
return editor;
}
void setEditorData(QWidget * editor, const QModelIndex & index) const
{
int value = index.model()->data(index, Qt::DisplayRole).toInt();
QSpinBox * spinBox = static_cast<QSpinBox *>(editor);
spinBox->setValue(value);
}
void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
{
QSpinBox * spinBox = static_cast<QSpinBox *>(editor);
spinBox->interpretText();
int value = spinBox->value();
model->setData(index, value, Qt::EditRole);
}
void updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex &) const
{
editor->setGeometry(option.rect);
}
};
SpinBoxDelegate * delegate = new SpinBoxDelegate(mEditView);
mEditView->setItemDelegateForColumn(2, delegate);
}
示例13: CreateGUI
//------------------------------------------------------------------------------
void MoleculeElDensSurfaceWidget::CreateGUI()
{
const QSettings s;
/// Layouts
// Main layout
QVBoxLayout* mainLayout = new QVBoxLayout();
/// Density
QHBoxLayout* densityMatrixLayout = new QHBoxLayout;
densityMatrixCheckBox_ = new QCheckBox( tr( "Density Matrix" ) );
densityMatrixCheckBox_->setChecked( false );
densityMatrixLayout->addWidget( densityMatrixCheckBox_ );
connect( densityMatrixCheckBox_, SIGNAL( toggled( bool ) ),
this, SLOT( DensityMatrixToggledSlot( bool ) ) );
mainLayout->addItem( densityMatrixLayout );
/// MEP
QHBoxLayout* mepLayout = new QHBoxLayout;
QCheckBox* mepCheckBox = new QCheckBox( tr( "Map Molecular Electrostatic Potential" ) );
mepCheckBox->setChecked( false );
mepLayout->addWidget( mepCheckBox );
connect( mepCheckBox, SIGNAL( toggled( bool ) ),
this, SLOT( MEPMappingToggledSlot( bool ) ) );
mainLayout->addItem( mepLayout );
/// Orbitals
// Table
table_ = new QTableWidget();
table_->setColumnCount( 4 );
QStringList labels;
labels << tr( "Generated" ) << tr( "Eigenvalue" ) << tr( "Occupation" ) << tr( "Type" );
table_->setHorizontalHeaderLabels( labels );
table_->setEditTriggers( QAbstractItemView::NoEditTriggers );
table_->setAlternatingRowColors( true );
connect( table_, SIGNAL( cellClicked( int, int ) ),
this, SLOT( TableCellClickedSlot( int, int ) ) );
table_->setSelectionBehavior( QAbstractItemView::SelectRows );
table_->setEnabled( false );
// Value & step
QLabel* valueLabel = new QLabel( tr( "Isosurface Value" ) );
valueSpinBox_ = new QDoubleSpinBox;
const double value = s.value( ISOVALUE_KEY, 0.05 ).toDouble();
valueSpinBox_->setValue( value );
valueSpinBox_->setSingleStep( 0.01 );
valueSpinBox_->setDecimals( 4 );
connect( valueSpinBox_, SIGNAL( valueChanged( double ) ),
this, SLOT( ComputeSteps() ) );
QHBoxLayout* valueLayout = new QHBoxLayout;
valueLayout->setSpacing( 40 );
valueLayout->addWidget( valueLabel );
valueLayout->addWidget( valueSpinBox_ );
// Check boxes for sign and nodal surface
signCheckBox_ = new QCheckBox( "Use both signs" );
nodalSurfaceCheckBox_ = new QCheckBox( "Generate Nodal Surface" );
Qt::CheckState checked = Qt::CheckState( s.value( BOTH_SIGNS_KEY, Qt::Unchecked ).toInt() );
signCheckBox_->setCheckState( checked );
checked = Qt::CheckState( s.value( NODAL_SURFACE_KEY, Qt::Unchecked ).toInt() );
nodalSurfaceCheckBox_->setCheckState( checked );
QHBoxLayout* checkBoxesLayout = new QHBoxLayout;
checkBoxesLayout->setSpacing( 40 );
checkBoxesLayout->addWidget( signCheckBox_ );
checkBoxesLayout->addWidget( nodalSurfaceCheckBox_ );
connect( signCheckBox_, SIGNAL( stateChanged( int ) ),
this, SLOT( BothSignsSlot( int ) ) );
connect( nodalSurfaceCheckBox_, SIGNAL( stateChanged( int ) ),
this, SLOT( NodalSurfaceSlot( int ) ) );
// Combo box for rendering style and transparency
QLabel* renderingStyleLabel = new QLabel( tr( "Rendering Style" ) );
renderingStyleComboBox_ = new QComboBox;
renderingStyleComboBox_->addItem( tr( "Solid" ), int( MolekelMolecule::SOLID ) );
renderingStyleComboBox_->addItem( tr( "Wireframe" ), int( MolekelMolecule::WIREFRAME ) );
renderingStyleComboBox_->addItem( tr( "Points" ), int( MolekelMolecule::POINTS ) );
renderingStyleComboBox_->setCurrentIndex( 0 );
connect( renderingStyleComboBox_, SIGNAL( currentIndexChanged( int ) ),
this, SLOT( RenderingStyleChangedSlot( int ) ) );
QBoxLayout* rsLayout = new QHBoxLayout;
rsLayout->addWidget( renderingStyleLabel );
rsLayout->addWidget( renderingStyleComboBox_ );
// Transparency.
QGridLayout* tLayout = new QGridLayout;
// density matrix
dmTransparencyWidget_ = new QDoubleSpinBox;
dmTransparencyWidget_->setRange( 0, 1 );
dmTransparencyWidget_->setSingleStep( 0.05 );
double transparency = s.value( DENSITY_MATRIX_TRANSPARENCY_KEY, 0.0 ).toDouble();
dmTransparencyWidget_->setValue( transparency );
connect( dmTransparencyWidget_, SIGNAL( valueChanged( double ) ), this, SLOT( DMTransparencyChangedSlot( double ) ) );
tLayout->addWidget( new QLabel( "Density Matrix" ), 0, 0 );
tLayout->addWidget( dmTransparencyWidget_, 0, 1 );
// negative
negTransparencyWidget_ = new QDoubleSpinBox;
negTransparencyWidget_->setRange( 0, 1 );
negTransparencyWidget_->setSingleStep( 0.05 );
transparency = s.value( NEGATIVE_TRANSPARENCY_KEY, 0.0 ).toDouble();
negTransparencyWidget_->setValue( transparency );
connect( negTransparencyWidget_, SIGNAL( valueChanged( double ) ), this, SLOT( NegTransparencyChangedSlot( double ) ) );
//.........这里部分代码省略.........
示例14: addItem
void QBoxLayoutProto::addItem(QLayoutItem *item)
{
QBoxLayout *boxitem = qscriptvalue_cast<QBoxLayout*>(thisObject());
if (boxitem)
boxitem->addItem(item);
}