本文整理汇总了C++中QScrollView::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollView::addChild方法的具体用法?C++ QScrollView::addChild怎么用?C++ QScrollView::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollView
的用法示例。
在下文中一共展示了QScrollView::addChild方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createPage
void XineConfig::createPage(const QString& cat, bool expert, QWidget* parent)
{
xine_cfg_entry_t* ent;
QScrollView* sv = new QScrollView(parent);
sv->setResizePolicy(QScrollView::AutoOneFit);
parent = new QWidget(sv->viewport());
sv->addChild(parent);
QGridLayout* grid = new QGridLayout(parent, 20 ,2);
grid->setColStretch(1,8);
grid->setSpacing(10);
grid->setMargin(10);
uint row = 0;
QString entCat;
/*********** read in xine config entries ***********/
ent = new xine_cfg_entry_t;
xine_config_get_first_entry(m_xine, ent);
do
{
entCat = QString(ent->key);
entCat = entCat.left(entCat.find("."));
if (entCat == cat)
{
if (((!expert) && (QString(NON_EXPERT_OPTIONS).contains(ent->key))) ||
((expert) && (!QString(NON_EXPERT_OPTIONS).contains(ent->key))))
{
m_entries.append(new XineConfigEntry(parent, grid, row, ent));
delete ent;
ent = new xine_cfg_entry_t;
row += 2;
}
}
}
while(xine_config_get_next_entry(m_xine, ent));
delete ent;
}
示例2: KBCatalogView
CharacterSelectorView::CharacterSelectorView(KBCatalog* catalog,QWidget *parent, Project::Ptr project)
: KBCatalogView(catalog,parent,project)
{
QVBoxLayout* layout = new QVBoxLayout( this );
layout->setResizeMode( QLayout::Minimum );
layout->setSpacing( KDialog::spacingHint() );
QHBox* bar = new QHBox(this);
bar->setSpacing( KDialog::spacingHint() );
layout->addWidget (bar);
QLabel *lTable = new QLabel( i18n( "Table:" ), bar );
_tableNum = new QSpinBox( 0, 255, 1, bar );
lTable->setBuddy( _tableNum );
bar->setStretchFactor( _tableNum, 1 );
QScrollView* scroll = new QScrollView( this );
_table = new KCharSelectTable(scroll,"charselector","helvetica",' ',0);
_table->setNumCols(16);
_table->setNumRows(16);
scroll->addChild(_table);
layout->addWidget (scroll);
connect( _table, SIGNAL( doubleClicked() ), this, SLOT( emitChar() ) );
connect( _tableNum, SIGNAL( valueChanged(int) ), this, SLOT( setTab(int) ));
connect( _catalog, SIGNAL( signalFileOpened(bool) ), this, SLOT (setDisabled (bool)));
connect( _catalog, SIGNAL( signalFileOpened(bool) ), _table, SLOT (setDisabled (bool)));
QWhatsThis::add(this,
i18n("<qt><p><b>Character Selector</b></p>"
"<p>This tool allows to insert special characters using "
"double click.</p></qt>"));
}
示例3: QDialog
FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name,
const QString &server, const QString &destination,
OPackageManager::Status status, const QString &category )
: QDialog( parent, QString::null, true, WStyle_ContextHelp )
{
setCaption( tr( "Filter packages" ) );
QVBoxLayout *layout = new QVBoxLayout( this );
QScrollView *sv = new QScrollView( this );
layout->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
layout = new QVBoxLayout( container, 4, 4 );
// Category
m_categoryCB = new QCheckBox( tr( "Category:" ), container );
QWhatsThis::add( m_categoryCB, tr( "Tap here to filter package list by application category." ) );
connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) );
m_category = new QComboBox( container );
QWhatsThis::add( m_category, tr( "Select the application category to filter by here." ) );
m_category->insertStringList( pm->categories() );
initItem( m_category, m_categoryCB, category );
layout->addWidget( m_categoryCB );
layout->addWidget( m_category );
// Package name
m_nameCB = new QCheckBox( tr( "Names containing:" ), container );
QWhatsThis::add( m_nameCB, tr( "Tap here to filter package list by package name." ) );
connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) );
m_name = new QLineEdit( name, container );
QWhatsThis::add( m_name, tr( "Enter the package name to filter by here." ) );
if ( !name.isNull() )
m_nameCB->setChecked( true );
m_name->setEnabled( !name.isNull() );
layout->addWidget( m_nameCB );
layout->addWidget( m_name );
// Status
m_statusCB = new QCheckBox( tr( "With the status:" ), container );
QWhatsThis::add( m_statusCB, tr( "Tap here to filter package list by the package status." ) );
connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) );
m_status = new QComboBox( container );
QWhatsThis::add( m_status, tr( "Select the package status to filter by here." ) );
connect( m_status, SIGNAL(activated(const QString&)), this, SLOT(slotStatusChanged(const QString&)) );
QString currStatus;
switch ( status )
{
case OPackageManager::All : currStatus = tr( "All" );
break;
case OPackageManager::Installed : currStatus = tr( "Installed" );
break;
case OPackageManager::NotInstalled : currStatus = tr( "Not installed" );
break;
case OPackageManager::Updated : currStatus = tr( "Updated" );
break;
default : currStatus = QString::null;
};
m_status->insertItem( tr( "All" ) );
m_status->insertItem( tr( "Installed" ) );
m_status->insertItem( tr( "Not installed" ) );
m_status->insertItem( tr( "Updated" ) );
initItem( m_status, m_statusCB, currStatus );
layout->addWidget( m_statusCB );
layout->addWidget( m_status );
// Server
m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container );
QWhatsThis::add( m_serverCB, tr( "Tap here to filter package list by source server." ) );
connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) );
m_server = new QComboBox( container );
QWhatsThis::add( m_server, tr( "Select the source server to filter by here." ) );
m_server->insertStringList( pm->servers() );
initItem( m_server, m_serverCB, server );
layout->addWidget( m_serverCB );
layout->addWidget( m_server );
// Destination
m_destCB = new QCheckBox( tr( "Installed on device at:" ), container );
QWhatsThis::add( m_destCB, tr( "Tap here to filter package list by destination where the package is installed to on this device." ) );
connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) );
m_destination = new QComboBox( container );
QWhatsThis::add( m_destination, tr( "Select the destination location to filter by here." ) );
m_destination->insertStringList( pm->destinations() );
initItem( m_destination, m_destCB, destination );
layout->addWidget( m_destCB );
layout->addWidget( m_destination );
}
示例4: if
void
MyPluginGUI::createGUI(DefaultGUIModel::variable_t *var, int size)
{
setMinimumSize(200, 300); // Qt API for setting window size
//overall GUI layout with a "horizontal box" copied from DefaultGUIModel
QBoxLayout *layout = new QHBoxLayout(this);
//additional GUI layouts with "vertical" layouts that will later
// be added to the overall "layout" above
QBoxLayout *leftlayout = new QVBoxLayout();
//QBoxLayout *rightlayout = new QVBoxLayout();
// this is a "horizontal button group"
QHButtonGroup *bttnGroup = new QHButtonGroup("Button Panel:", this);
// we add two pushbuttons to the button group
QPushButton *aBttn = new QPushButton("Button A", bttnGroup);
QPushButton *bBttn = new QPushButton("Button B", bttnGroup);
// clicked() is a Qt signal that is given to pushbuttons. The connect()
// function links the clicked() event to a function that is defined
// as a "private slot:" in the header.
QObject::connect(aBttn, SIGNAL(clicked()), this, SLOT(aBttn_event()));
QObject::connect(bBttn, SIGNAL(clicked()), this, SLOT(bBttn_event()));
//these 3 utility buttons are copied from DefaultGUIModel
QHBox *utilityBox = new QHBox(this);
pauseButton = new QPushButton("Pause", utilityBox);
pauseButton->setToggleButton(true);
QObject::connect(pauseButton, SIGNAL(toggled(bool)), this, SLOT(pause(bool)));
QPushButton *modifyButton = new QPushButton("Modify", utilityBox);
QObject::connect(modifyButton, SIGNAL(clicked(void)), this, SLOT(modify(void)));
QPushButton *unloadButton = new QPushButton("Unload", utilityBox);
QObject::connect(unloadButton, SIGNAL(clicked(void)), this, SLOT(exit(void)));
// add custom button group at the top of the layout
leftlayout->addWidget(bttnGroup);
// copied from DefaultGUIModel DO NOT EDIT
// this generates the text boxes and labels
QScrollView *sv = new QScrollView(this);
sv->setResizePolicy(QScrollView::AutoOneFit);
leftlayout->addWidget(sv);
QWidget *viewport = new QWidget(sv->viewport());
sv->addChild(viewport);
QGridLayout *scrollLayout = new QGridLayout(viewport, 1, 2);
size_t nstate = 0, nparam = 0, nevent = 0, ncomment = 0;
for (size_t i = 0; i < num_vars; i++)
{
if (vars[i].flags & (PARAMETER | STATE | EVENT | COMMENT))
{
param_t param;
param.label = new QLabel(vars[i].name, viewport);
scrollLayout->addWidget(param.label, parameter.size(), 0);
param.edit = new DefaultGUILineEdit(viewport);
scrollLayout->addWidget(param.edit, parameter.size(), 1);
QToolTip::add(param.label, vars[i].description);
QToolTip::add(param.edit, vars[i].description);
if (vars[i].flags & PARAMETER)
{
if (vars[i].flags & DOUBLE)
{
param.edit->setValidator(new QDoubleValidator(param.edit));
param.type = PARAMETER | DOUBLE;
}
else if (vars[i].flags & UINTEGER)
{
QIntValidator *validator = new QIntValidator(param.edit);
param.edit->setValidator(validator);
validator->setBottom(0);
param.type = PARAMETER | UINTEGER;
}
else if (vars[i].flags & INTEGER)
{
param.edit->setValidator(new QIntValidator(param.edit));
param.type = PARAMETER | INTEGER;
}
else
param.type = PARAMETER;
param.index = nparam++;
param.str_value = new QString;
}
else if (vars[i].flags & STATE)
{
param.edit->setReadOnly(true);
param.edit->setPaletteForegroundColor(Qt::darkGray);
param.type = STATE;
param.index = nstate++;
}
else if (vars[i].flags & EVENT)
{
param.edit->setReadOnly(true);
//.........这里部分代码省略.........
示例5: pageName
HelixConfigDialogBase::HelixConfigDialogBase( HelixEngine *engine, amaroK::PluginConfig *config, QWidget *p )
: QTabWidget( p )
, m_core(0)
, m_plugin(0)
, m_codec(0)
, m_device(0)
, m_engine( engine )
{
int row = 0;
QString currentPage;
QWidget *parent = 0;
QGridLayout *grid = 0;
QScrollView *sv = 0;
QString pageName( i18n("Main") );
addTab( sv = new QScrollView, pageName );
parent = new QWidget( sv->viewport() );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setHScrollBarMode( QScrollView::AlwaysOff );
sv->setFrameShape( QFrame::NoFrame );
sv->addChild( parent );
grid = new QGridLayout( parent, /*rows*/20, /*cols*/2, /*margin*/10, /*spacing*/10 );
grid->setColStretch( 0, 1 );
grid->setColStretch( 1, 1 );
if( sv )
sv->setMinimumWidth( grid->sizeHint().width() + 20 );
engine->m_coredir = HelixConfig::coreDirectory();
m_core = new HelixConfigEntry( parent, engine->m_coredir,
config, row,
i18n("Helix/Realplay core directory"),
HelixConfig::coreDirectory().utf8(),
i18n("This is the directory where clntcore.so is located"));
++row;
engine->m_pluginsdir = HelixConfig::pluginDirectory();
m_plugin = new HelixConfigEntry( parent, engine->m_pluginsdir,
config, row,
i18n("Helix/Realplay plugins directory"),
HelixConfig::pluginDirectory().utf8(),
i18n("This is the directory where, for example, vorbisrend.so is located"));
++row;
engine->m_codecsdir = HelixConfig::codecsDirectory();
m_codec = new HelixConfigEntry( parent, engine->m_codecsdir,
config, row,
i18n("Helix/Realplay codecs directory"),
HelixConfig::codecsDirectory().utf8(),
i18n("This is the directory where, for example, cvt1.so is located"));
++row;
grid->addMultiCellWidget( new KSeparator( KSeparator::Horizontal, parent ), row, row, 0, 1 );
++row;
m_device = new HelixSoundDevice( parent, config, row, engine );
// lets find the logo if we can
QPixmap *pm = 0;
QString logo = HelixConfig::coreDirectory();
if (logo.isEmpty())
logo = HELIX_LIBS "/common";
logo.append("/../share/");
QString tmp = logo;
tmp.append("hxplay/logo.png");
if (QFileInfo(tmp).exists())
{
logo = tmp;
pm = new QPixmap(logo);
}
else
{
tmp = logo;
tmp.append("realplay/logo.png");
if (QFileInfo(tmp).exists())
{
logo = tmp;
pm = new QPixmap(logo);
}
}
if (pm)
{
QLabel *l = new QLabel(parent);
l->setPixmap(*pm);
grid->addMultiCellWidget( l, 20, 20, 1, 1, Qt::AlignRight );
}
entries.setAutoDelete( true );
pageName = i18n("Plugins");
addTab( sv = new QScrollView, pageName );
parent = new QWidget( sv->viewport() );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->addChild( parent );
//.........这里部分代码省略.........
示例6: if
void
SigGen::createGUI(DefaultGUIModel::variable_t *var, int size)
{
QBoxLayout *layout = new QVBoxLayout(this);
QVButtonGroup *modeBox = new QVButtonGroup("Signal Type", this);
waveShape = new QComboBox(FALSE, modeBox, "Signal Type:");
waveShape->insertItem("Sine Wave");
waveShape->insertItem("Monophasic Square Wave");
waveShape->insertItem("Biphasic Square Wave");
waveShape->insertItem("Sawtooth Wave");
waveShape->insertItem("ZAP Stimulus");
QToolTip::add(waveShape, "Choose a signal to generate.");
QObject::connect(waveShape,SIGNAL(activated(int)), this, SLOT(updateMode(int)));
// add custom GUI components to layout above default_gui_model components
layout->addWidget(modeBox);
//layout->addWidget(waveShape);
QScrollView *sv = new QScrollView(this);
sv->setResizePolicy(QScrollView::AutoOneFit);
layout->addWidget(sv);
QWidget *viewport = new QWidget(sv->viewport());
sv->addChild(viewport);
QGridLayout *scrollLayout = new QGridLayout(viewport, 1, 2);
size_t nstate = 0, nparam = 0, nevent = 0, ncomment = 0;
for (size_t i = 0; i < num_vars; i++)
{
if (vars[i].flags & (PARAMETER | STATE | EVENT | COMMENT))
{
param_t param;
param.label = new QLabel(vars[i].name, viewport);
scrollLayout->addWidget(param.label, parameter.size(), 0);
param.edit = new DefaultGUILineEdit(viewport);
scrollLayout->addWidget(param.edit, parameter.size(), 1);
QToolTip::add(param.label, vars[i].description);
QToolTip::add(param.edit, vars[i].description);
if (vars[i].flags & PARAMETER)
{
if (vars[i].flags & DOUBLE)
{
param.edit->setValidator(new QDoubleValidator(param.edit));
param.type = PARAMETER | DOUBLE;
}
else if (vars[i].flags & UINTEGER)
{
QIntValidator *validator = new QIntValidator(param.edit);
param.edit->setValidator(validator);
validator->setBottom(0);
param.type = PARAMETER | UINTEGER;
}
else if (vars[i].flags & INTEGER)
{
param.edit->setValidator(new QIntValidator(param.edit));
param.type = PARAMETER | INTEGER;
}
else
param.type = PARAMETER;
param.index = nparam++;
param.str_value = new QString;
}
else if (vars[i].flags & STATE)
{
param.edit->setReadOnly(true);
param.edit->setPaletteForegroundColor(Qt::darkGray);
param.type = STATE;
param.index = nstate++;
}
else if (vars[i].flags & EVENT)
{
param.edit->setReadOnly(true);
param.type = EVENT;
param.index = nevent++;
}
else if (vars[i].flags & COMMENT)
{
param.type = COMMENT;
param.index = ncomment++;
}
parameter[vars[i].name] = param;
}
}
QHBox *hbox1 = new QHBox(this);
pauseButton = new QPushButton("Pause", hbox1);
pauseButton->setToggleButton(true);
QObject::connect(pauseButton,SIGNAL(toggled(bool)),this,SLOT(pause(bool)));
QPushButton *modifyButton = new QPushButton("Modify", hbox1);
QObject::connect(modifyButton,SIGNAL(clicked(void)),this,SLOT(modify(void)));
QPushButton *unloadButton = new QPushButton("Unload", hbox1);
QObject::connect(unloadButton,SIGNAL(clicked(void)),this,SLOT(exit(void)));
layout->addWidget(hbox1);
//.........这里部分代码省略.........
示例7: KDialogBase
Kleo::KeyApprovalDialog::KeyApprovalDialog( const std::vector<Item> & recipients,
const std::vector<GpgME::Key> & sender,
QWidget * parent, const char * name,
bool modal )
: KDialogBase( parent, name, modal, i18n("Encryption Key Approval"), Ok|Cancel, Ok ),
d( 0 )
{
assert( !recipients.empty() );
d = new Private();
QFrame *page = makeMainWidget();
QVBoxLayout * vlay = new QVBoxLayout( page, 0, spacingHint() );
vlay->addWidget( new QLabel( i18n("The following keys will be used for encryption:"), page ) );
QScrollView * sv = new QScrollView( page );
sv->setResizePolicy( QScrollView::AutoOneFit );
vlay->addWidget( sv );
QWidget * view = new QWidget( sv->viewport() );
QGridLayout * glay = new QGridLayout( view, 3, 2, marginHint(), spacingHint() );
glay->setColStretch( 1, 1 );
sv->addChild( view );
int row = -1;
if ( !sender.empty() ) {
++row;
glay->addWidget( new QLabel( i18n("Your keys:"), view ), row, 0 );
d->selfRequester = new EncryptionKeyRequester( true, EncryptionKeyRequester::AllProtocols, view );
d->selfRequester->setKeys( sender );
glay->addWidget( d->selfRequester, row, 1 );
++row;
glay->addMultiCellWidget( new KSeparator( Horizontal, view ), row, row, 0, 1 );
}
const QStringList prefs = preferencesStrings();
for ( std::vector<Item>::const_iterator it = recipients.begin() ; it != recipients.end() ; ++it ) {
++row;
glay->addWidget( new QLabel( i18n("Recipient:"), view ), row, 0 );
glay->addWidget( new QLabel( it->address, view ), row, 1 );
d->addresses.push_back( it->address );
++row;
glay->addWidget( new QLabel( i18n("Encryption keys:"), view ), row, 0 );
KeyRequester * req = new EncryptionKeyRequester( true, EncryptionKeyRequester::AllProtocols, view );
req->setKeys( it->keys );
glay->addWidget( req, row, 1 );
d->requesters.push_back( req );
++row;
glay->addWidget( new QLabel( i18n("Encryption preference:"), view ), row, 0 );
QComboBox * cb = new QComboBox( false, view );
cb->insertStringList( prefs );
glay->addWidget( cb, row, 1 );
cb->setCurrentItem( pref2cb( it->pref ) );
connect( cb, SIGNAL(activated(int)), SLOT(slotPrefsChanged()) );
d->preferences.push_back( cb );
}
// calculate the optimal width for the dialog
const int dialogWidth = marginHint()
+ sv->frameWidth()
+ view->sizeHint().width()
+ sv->verticalScrollBar()->sizeHint().width()
+ sv->frameWidth()
+ marginHint()
+ 2;
// calculate the optimal height for the dialog
const int dialogHeight = marginHint()
+ fontMetrics().height()
+ spacingHint()
+ sv->frameWidth()
+ view->sizeHint().height()
+ sv->horizontalScrollBar()->sizeHint().height()
+ sv->frameWidth()
+ spacingHint()
+ actionButton( KDialogBase::Cancel )->sizeHint().height()
+ marginHint()
+ 2;
// don't make the dialog too large
const QRect desk = KGlobalSettings::desktopGeometry( this );
setInitialSize( QSize( kMin( dialogWidth, 3 * desk.width() / 4 ),
kMin( dialogHeight, 7 * desk.height() / 8 ) ) );
}
示例8: if
void
WaveMaker::createGUI(DefaultGUIModel::variable_t *var, int size)
{
QBoxLayout *layout = new QHBoxLayout(this); // overall GUI layout
// Left side GUI
QBoxLayout *leftlayout = new QVBoxLayout();
QHButtonGroup *fileBox = new QHButtonGroup("File:", this);
QPushButton *loadBttn = new QPushButton("Load File", fileBox);
QPushButton *previewBttn = new QPushButton("Preview File", fileBox);
QObject::connect(loadBttn, SIGNAL(clicked()), this, SLOT(loadFile()));
QObject::connect(previewBttn, SIGNAL(clicked()), this, SLOT(previewFile()));
QHBox *utilityBox = new QHBox(this);
pauseButton = new QPushButton("Pause", utilityBox);
pauseButton->setToggleButton(true);
QObject::connect(pauseButton, SIGNAL(toggled(bool)), this, SLOT(pause(bool)));
QObject::connect(pauseButton, SIGNAL(toggled(bool)), loadBttn, SLOT(setEnabled(bool)));
QPushButton *modifyButton = new QPushButton("Modify", utilityBox);
QObject::connect(modifyButton, SIGNAL(clicked(void)), this, SLOT(modify(void)));
QPushButton *unloadButton = new QPushButton("Unload", utilityBox);
QObject::connect(unloadButton, SIGNAL(clicked(void)), this, SLOT(exit(void)));
QObject::connect(pauseButton, SIGNAL(toggled(bool)), modifyButton, SLOT(setEnabled(bool)));
QToolTip::add(pauseButton, "Start/Stop Plug-in");
QToolTip::add(modifyButton, "Commit Changes to Parameter Values");
QToolTip::add(unloadButton, "Close Plug-in");
// Add custom left side GUI components to layout above default_gui_model components
leftlayout->addWidget(fileBox);
QScrollView *sv = new QScrollView(this);
sv->setResizePolicy(QScrollView::AutoOneFit);
leftlayout->addWidget(sv);
QWidget *viewport = new QWidget(sv->viewport());
sv->addChild(viewport);
QGridLayout *scrollLayout = new QGridLayout(viewport, 1, 2);
size_t nstate = 0, nparam = 0, nevent = 0, ncomment = 0;
for (size_t i = 0; i < num_vars; i++)
{
if (vars[i].flags & (PARAMETER | STATE | EVENT | COMMENT))
{
param_t param;
param.label = new QLabel(vars[i].name, viewport);
scrollLayout->addWidget(param.label, parameter.size(), 0);
param.edit = new DefaultGUILineEdit(viewport);
scrollLayout->addWidget(param.edit, parameter.size(), 1);
QToolTip::add(param.label, vars[i].description);
QToolTip::add(param.edit, vars[i].description);
if (vars[i].flags & PARAMETER)
{
if (vars[i].flags & DOUBLE)
{
param.edit->setValidator(new QDoubleValidator(param.edit));
param.type = PARAMETER | DOUBLE;
}
else if (vars[i].flags & UINTEGER)
{
QIntValidator *validator = new QIntValidator(param.edit);
param.edit->setValidator(validator);
validator->setBottom(0);
param.type = PARAMETER | UINTEGER;
}
else if (vars[i].flags & INTEGER)
{
param.edit->setValidator(new QIntValidator(param.edit));
param.type = PARAMETER | INTEGER;
}
else
param.type = PARAMETER;
param.index = nparam++;
param.str_value = new QString;
}
else if (vars[i].flags & STATE)
{
param.edit->setReadOnly(true);
param.edit->setPaletteForegroundColor(Qt::darkGray);
param.type = STATE;
param.index = nstate++;
}
else if (vars[i].flags & EVENT)
{
param.edit->setReadOnly(true);
param.type = EVENT;
param.index = nevent++;
}
else if (vars[i].flags & COMMENT)
{
param.type = COMMENT;
param.index = ncomment++;
}
parameter[vars[i].name] = param;
}
}
//.........这里部分代码省略.........
示例9: if
// The constructor sets up the GUI, laying out the parameters on the left and
// the two plots on the right. There's nothing special here, it's just long.
// The code for the labels and text boxes for the parameters (on the left) is
// boilerplate ripped directly from default_gui_model, and should really be
// refactored out of here.
Istep::Istep(void) :
QWidget(MainWindow::getInstance()->centralWidget()),
Workspace::Instance("Istep", ::vars, ::num_vars),
period(1.0),
delay(0.0),
Amin(-100.0),
Amax(100.0),
Nsteps(20),
Ncycles(1),
duty(50),
offset(0.0),
factor(200.0),
periodsSincePlot(0)
{
setCaption(QString::number(getID()) + " Istep");
QBoxLayout *layout = new QHBoxLayout(this); // overall GUI layout
QBoxLayout *leftLayout = new QVBoxLayout();
QHBox *utilityBox = new QHBox(this);
pauseButton = new QPushButton("Pause", utilityBox);
pauseButton->setToggleButton(true);
QPushButton *modifyButton = new QPushButton("Modify", utilityBox);
QPushButton *unloadButton = new QPushButton("Unload", utilityBox);
QObject::connect(pauseButton, SIGNAL(toggled(bool)), this, SLOT(pause(bool)));
QObject::connect(modifyButton, SIGNAL(clicked(void)), this, SLOT(modify(void)));
QObject::connect(unloadButton, SIGNAL(clicked(void)), this, SLOT(exit(void)));
QObject::connect(pauseButton, SIGNAL(toggled(bool)), modifyButton, SLOT(setEnabled(bool)));
QToolTip::add(pauseButton, "Start/Stop Istep protocol");
QToolTip::add(modifyButton, "Commit changes to parameter values and reset");
QToolTip::add(unloadButton, "Close plug-in");
// create default_gui_model GUI DO NOT EDIT
QScrollView *sv = new QScrollView(this);
sv->setResizePolicy(QScrollView::AutoOneFit);
sv->setHScrollBarMode(QScrollView::AlwaysOff);
QWidget *viewport = new QWidget(sv->viewport());
sv->addChild(viewport);
QGridLayout *scrollLayout = new QGridLayout(viewport, 1, 2);
size_t nstate = 0, nparam = 0, nevent = 0, ncomment = 0;
for (size_t i = 0; i < num_vars; i++)
{
if (vars[i].flags & (PARAMETER | STATE | EVENT | COMMENT))
{
param_t param = {0};
param.label = new QLabel(vars[i].name, viewport);
scrollLayout->addWidget(param.label, parameter.size(), 0);
param.edit = new DefaultGUILineEdit(viewport);
scrollLayout->addWidget(param.edit, parameter.size(), 1);
QToolTip::add(param.label, vars[i].description);
QToolTip::add(param.edit, vars[i].description);
if (vars[i].flags & PARAMETER)
{
if (vars[i].flags & DOUBLE)
{
param.edit->setValidator(new QDoubleValidator(param.edit));
param.type = PARAMETER | DOUBLE;
}
else if (vars[i].flags & UINTEGER)
{
QIntValidator *validator = new QIntValidator(param.edit);
param.edit->setValidator(validator);
validator->setBottom(0);
param.type = PARAMETER | UINTEGER;
}
else if (vars[i].flags & INTEGER)
{
param.edit->setValidator(new QIntValidator(param.edit));
param.type = PARAMETER | INTEGER;
}
else
param.type = PARAMETER;
param.index = nparam++;
param.str_value = new QString;
}
else if (vars[i].flags & STATE)
{
param.edit->setReadOnly(true);
param.type = STATE;
param.index = nstate++;
}
else if (vars[i].flags & EVENT)
{
param.edit->setReadOnly(true);
param.type = EVENT;
param.index = nevent++;
}
else if (vars[i].flags & COMMENT)
{
//.........这里部分代码省略.........
示例10: if
void
TDDDriver::createGUI(DefaultGUIModel::variable_t *var, int size)
{
setMinimumSize(200, 300); // Qt API for setting window size
//overall GUI layout with a "horizontal box" copied from DefaultGUIModel
QBoxLayout *layout = new QHBoxLayout(this);
//additional GUI layouts with "vertical" layouts that will later
// be added to the overall "layout" above
QBoxLayout *leftlayout = new QVBoxLayout();
QBoxLayout *rightlayout = new QVBoxLayout();
//these 3 utility buttons are copied from DefaultGUIModel
QHBox *utilityBox = new QHBox(this);
pauseButton = new QPushButton("Pause", utilityBox);
pauseButton->setToggleButton(true);
QObject::connect(pauseButton, SIGNAL(toggled(bool)), this, SLOT(pause(bool)));
QPushButton *modifyButton = new QPushButton("Modify", utilityBox);
QObject::connect(modifyButton, SIGNAL(clicked(void)), this, SLOT(modify(void)));
QPushButton *unloadButton = new QPushButton("Unload", utilityBox);
QObject::connect(unloadButton, SIGNAL(clicked(void)), this, SLOT(exit(void)));
QPixmap *drawsurface = new QPixmap(640,480);
QWidget *drawplane = new QWidget;
drawplane->resize(640, drawplane->width());
drawsurface->fill(Qt::black);
bitBlt(drawplane,0,0,drawsurface);
printf("Widget Width = %d \n", drawplane->width());
rightlayout->addWidget(drawplane);
// copied from DefaultGUIModel DO NOT EDIT
// this generates the text boxes and labels
QScrollView *sv = new QScrollView(this);
sv->setResizePolicy(QScrollView::AutoOneFit);
leftlayout->addWidget(sv);
QWidget *viewport = new QWidget(sv->viewport());
sv->addChild(viewport);
QGridLayout *scrollLayout = new QGridLayout(viewport, 1, 2);
size_t nstate = 0, nparam = 0, nevent = 0, ncomment = 0;
for (size_t i = 0; i < num_vars; i++)
{
if (vars[i].flags & (PARAMETER | STATE | EVENT | COMMENT))
{
param_t param;
param.label = new QLabel(vars[i].name, viewport);
scrollLayout->addWidget(param.label, parameter.size(), 0);
param.edit = new DefaultGUILineEdit(viewport);
scrollLayout->addWidget(param.edit, parameter.size(), 1);
QToolTip::add(param.label, vars[i].description);
QToolTip::add(param.edit, vars[i].description);
if (vars[i].flags & PARAMETER)
{
if (vars[i].flags & DOUBLE)
{
param.edit->setValidator(new QDoubleValidator(param.edit));
param.type = PARAMETER | DOUBLE;
}
else if (vars[i].flags & UINTEGER)
{
QIntValidator *validator = new QIntValidator(param.edit);
param.edit->setValidator(validator);
validator->setBottom(0);
param.type = PARAMETER | UINTEGER;
}
else if (vars[i].flags & INTEGER)
{
param.edit->setValidator(new QIntValidator(param.edit));
param.type = PARAMETER | INTEGER;
}
else
param.type = PARAMETER;
param.index = nparam++;
param.str_value = new QString;
}
else if (vars[i].flags & STATE)
{
param.edit->setReadOnly(true);
param.edit->setPaletteForegroundColor(Qt::darkGray);
param.type = STATE;
param.index = nstate++;
}
else if (vars[i].flags & EVENT)
{
param.edit->setReadOnly(true);
param.type = EVENT;
param.index = nevent++;
}
else if (vars[i].flags & COMMENT)
{
param.type = COMMENT;
param.index = ncomment++;
}
//.........这里部分代码省略.........
示例11: QDialog
IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp)
{
setCaption(tr("Settings") );
m_config = new Config("OpieIRC");
m_config->setGroup("OpieIRC");
QHBoxLayout *l = new QHBoxLayout(this, 2, 2);
OTabWidget *tw = new OTabWidget(this);
l->addWidget(tw);
/* General Configuration */
QWidget *genwidget = new QWidget(tw);
QGridLayout *layout = new QGridLayout(genwidget, 1, 4, 5, 0);
QLabel *label = new QLabel(tr("Lines displayed :"), genwidget);
layout->addWidget(label, 0, 0);
m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget);
QWhatsThis::add(m_lines, tr("Amount of lines to be displayed in chats before old lines get deleted - this is necessary to restrain memory consumption. Set to 0 if you don't need this"));
QIntValidator *validator = new QIntValidator(this);
validator->setTop(10000);
validator->setBottom(0);
m_lines->setValidator(validator);
layout->addWidget(m_lines, 0, 1);
/*
* include timestamp
*/
m_displayTime = new QCheckBox( tr("Display time in chat log"), genwidget );
m_displayTime->setChecked( m_config->readBoolEntry("DisplayTime", false) );
layout->addMultiCellWidget(m_displayTime, 1, 1, 0, 4 );
// add a spacer
layout->addItem( new QSpacerItem(1,1, QSizePolicy::Minimum,
QSizePolicy::MinimumExpanding),
2, 0 );
tw->addTab(genwidget, "opieirc/settings", tr("General"));
/* Color configuration */
QScrollView *view = new QScrollView(this);
view->setResizePolicy(QScrollView::AutoOneFit);
view->setFrameStyle( QFrame::NoFrame );
QWidget *widget = new QWidget(view->viewport());
view->addChild(widget);
layout = new QGridLayout(widget, 7, 2, 5, 0);
label = new QLabel(tr("Background color :"), widget);
layout->addWidget(label, 0, 0);
m_background = new OColorButton(widget, m_config->readEntry("BackgroundColor", "#FFFFFF"));
QWhatsThis::add(m_background, tr("Background color to be used in chats"));
layout->addWidget(m_background, 0, 1);
label = new QLabel(tr("Normal text color :"), widget);
layout->addWidget(label, 1, 0);
m_text = new OColorButton(widget, m_config->readEntry("TextColor", "#000000"));
QWhatsThis::add(m_text, tr("Text color to be used in chats"));
layout->addWidget(m_text, 1, 1);
label = new QLabel(tr("Error color :"), widget);
layout->addWidget(label, 2, 0);
m_error = new OColorButton(widget, m_config->readEntry("ErrorColor", "#FF0000"));
QWhatsThis::add(m_error, tr("Text color to be used to display errors"));
layout->addWidget(m_error, 2, 1);
label = new QLabel(tr("Text written by yourself :"), widget);
layout->addWidget(label, 3, 0);
m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000"));
QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself"));
layout->addWidget(m_self, 3, 1);
label = new QLabel(tr("Text written by others :"), widget);
layout->addWidget(label, 4, 0);
m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB"));
QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others"));
layout->addWidget(m_other, 4, 1);
label = new QLabel(tr("Text written by the server :"), widget);
layout->addWidget(label, 5, 0);
m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF"));
QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server"));
layout->addWidget(m_server, 5, 1);
label = new QLabel(tr("Notifications :"), widget);
layout->addWidget(label, 6, 0);
m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#006400"));
QWhatsThis::add(m_notification, tr("Text color to be used to display notifications"));
layout->addWidget(m_notification, 6, 1);
tw->addTab(view, "opieirc/colors", tr("Colors"));
/*
* IRC EditLine KeyConfiguration
*/
m_keyConf = new Opie::Ui::OKeyConfigWidget(tw, "KEyConfig GUI" );
m_keyConf->setChangeMode( OKeyConfigWidget::Queue );
m_keyConf->insert( tr("Keyboard Shortcuts"),
IRCHistoryLineEdit::keyConfigInstance() );
m_keyConf->load();
tw->addTab(m_keyConf, "SettingsIcon", tr("Keyboard Shortcuts") );
tw->setCurrentTab( genwidget );
QPEApplication::showDialog( this );
}
示例12: toggle
Expert::Expert( QWidget *parent ) : QTabDialog( parent )
{
m_dependencies = new QDict< QList<IInput> >(257);
m_dependencies->setAutoDelete(TRUE);
m_inputWidgets = new QDict< IInput >;
m_switches = new QDict< QObject >;
m_changed = FALSE;
setHelpButton();
QListIterator<ConfigOption> options = Config::instance()->iterator();
QVBoxLayout *pageLayout = 0;
QFrame *page = 0;
ConfigOption *option = 0;
for (options.toFirst();(option=options.current());++options)
{
switch(option->kind())
{
case ConfigOption::O_Info:
{
if (pageLayout) pageLayout->addStretch(1);
QScrollView *view = new QScrollView(this);
view->setVScrollBarMode(QScrollView::Auto);
view->setHScrollBarMode(QScrollView::AlwaysOff);
view->setResizePolicy(QScrollView::AutoOneFit);
page = new QFrame( view->viewport(), option->name() );
pageLayout = new QVBoxLayout(page);
pageLayout->setMargin(10);
view->addChild(page);
addTab(view,option->name());
QWhatsThis::add(page, option->docs().simplifyWhiteSpace() );
QToolTip::add(page, option->docs() );
}
break;
case ConfigOption::O_String:
{
ASSERT(page!=0);
InputString::StringMode sm=InputString::StringFree;
switch(((ConfigString *)option)->widgetType())
{
case ConfigString::String: sm=InputString::StringFree; break;
case ConfigString::File: sm=InputString::StringFile; break;
case ConfigString::Dir: sm=InputString::StringDir; break;
}
InputString *inputString = new InputString(
option->name(), // name
page, // widget
*((ConfigString *)option)->valueRef(), // variable
sm // type
);
pageLayout->addWidget(inputString);
QWhatsThis::add(inputString, option->docs().simplifyWhiteSpace() );
QToolTip::add(inputString,option->docs());
connect(inputString,SIGNAL(changed()),SLOT(changed()));
m_inputWidgets->insert(option->name(),inputString);
addDependency(m_switches,option->dependsOn(),option->name());
}
break;
case ConfigOption::O_Enum:
{
ASSERT(page!=0);
InputString *inputString = new InputString(
option->name(), // name
page, // widget
*((ConfigEnum *)option)->valueRef(), // variable
InputString::StringFixed // type
);
pageLayout->addWidget(inputString);
QStrListIterator sli=((ConfigEnum *)option)->iterator();
for (sli.toFirst();sli.current();++sli)
{
inputString->addValue(sli.current());
}
inputString->init();
QWhatsThis::add(inputString, option->docs().simplifyWhiteSpace() );
QToolTip::add(inputString, option->docs());
connect(inputString,SIGNAL(changed()),SLOT(changed()));
m_inputWidgets->insert(option->name(),inputString);
addDependency(m_switches,option->dependsOn(),option->name());
}
break;
case ConfigOption::O_List:
{
ASSERT(page!=0);
InputStrList::ListMode lm=InputStrList::ListString;
switch(((ConfigList *)option)->widgetType())
{
case ConfigList::String: lm=InputStrList::ListString; break;
case ConfigList::File: lm=InputStrList::ListFile; break;
case ConfigList::Dir: lm=InputStrList::ListDir; break;
case ConfigList::FileAndDir: lm=InputStrList::ListFileDir; break;
}
InputStrList *inputStrList = new InputStrList(
option->name(), // name
page, // widget
*((ConfigList *)option)->valueRef(), // variable
lm // type
);
pageLayout->addWidget(inputStrList);
//.........这里部分代码省略.........
示例13: QWidget
// ---- initSettings ----------------------------------------------------------
QWidget *Configuration::initSettings(Cfg &cfg)
{
QWidget *control = new QWidget( _mainWidget );
QFontMetrics fm = fontMetrics();
int fh = fm.height();
QVBoxLayout *vb = new QVBoxLayout( control );
QScrollView *sv = new QScrollView( control );
vb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setSpacing( 4 );
layout->setMargin( 4 );
QLabel *label = new QLabel( tr( "Enter currency symbol:" ), container );
QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) );
label->setMaximumHeight( fh + 3 );
layout->addWidget( label, 0, 0 );
symbolEdit = new QLineEdit( cfg.getCurrencySymbol(), container );
QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) );
symbolEdit->setMaximumHeight( fh + 5 );
symbolEdit->setFocus();
layout->addWidget( symbolEdit, 0, 1 );
lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), container );
QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) );
lockCB->setChecked( cfg.getShowLocks() );
layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 );
balCB = new QCheckBox( tr( "Show checkbook balances" ), container );
QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) );
balCB->setMaximumHeight( fh + 5 );
balCB->setChecked( cfg.getShowBalances() );
layout->addMultiCellWidget( balCB, 2, 2, 0, 1 );
openLastBookCB = new QCheckBox( tr("Open last checkbook" ), container );
QWhatsThis::add( openLastBookCB, tr("Click here to select whether the last open checkbook will be opened at startup.") );
openLastBookCB->setMaximumHeight(fh+5);
openLastBookCB->setChecked( cfg.isOpenLastBook() );
layout->addMultiCellWidget( openLastBookCB, 3, 3, 0, 1 );
lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container );
QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") );
lastTabCB->setMaximumHeight(fh+5);
lastTabCB->setChecked( cfg.isShowLastTab() );
layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 );
savePayees = new QCheckBox( tr("Save new description as payee"), container );
QWhatsThis::add( savePayees, tr("Click here to save new descriptions in the list of payess.") );
savePayees->setMaximumHeight(fh+5);
savePayees->setChecked( cfg.getSavePayees() );
layout->addMultiCellWidget( savePayees, 5, 5, 0, 1 );
smallFontCB = new QCheckBox( tr( "Use smaller font for list" ), container );
QWhatsThis::add( smallFontCB, tr( "Click here to select smaller font for transactions." ) );
smallFontCB->setChecked( cfg.getUseSmallFont() );
layout->addMultiCellWidget( smallFontCB, 6, 6, 0, 1 );
return(control);
}