本文整理汇总了C++中QWidget类的典型用法代码示例。如果您正苦于以下问题:C++ QWidget类的具体用法?C++ QWidget怎么用?C++ QWidget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WiresharkDialog
Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
WiresharkDialog(parent, cf),
ui(new Ui::Iax2AnalysisDialog),
port_src_fwd_(0),
port_dst_fwd_(0),
port_src_rev_(0),
port_dst_rev_(0),
save_payload_error_(TAP_IAX2_NO_ERROR)
{
ui->setupUi(this);
loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5);
setWindowSubtitle(tr("IAX2 Stream Analysis"));
ui->progressFrame->hide();
stream_ctx_menu_.addAction(ui->actionGoToPacket);
stream_ctx_menu_.addAction(ui->actionNextProblem);
stream_ctx_menu_.addSeparator();
stream_ctx_menu_.addAction(ui->actionSaveAudio);
stream_ctx_menu_.addAction(ui->actionSaveForwardAudio);
stream_ctx_menu_.addAction(ui->actionSaveReverseAudio);
stream_ctx_menu_.addSeparator();
stream_ctx_menu_.addAction(ui->actionSaveCsv);
stream_ctx_menu_.addAction(ui->actionSaveForwardCsv);
stream_ctx_menu_.addAction(ui->actionSaveReverseCsv);
stream_ctx_menu_.addSeparator();
stream_ctx_menu_.addAction(ui->actionSaveGraph);
ui->forwardTreeWidget->installEventFilter(this);
ui->forwardTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->forwardTreeWidget, SIGNAL(customContextMenuRequested(QPoint)),
SLOT(showStreamMenu(QPoint)));
ui->reverseTreeWidget->installEventFilter(this);
ui->reverseTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->reverseTreeWidget, SIGNAL(customContextMenuRequested(QPoint)),
SLOT(showStreamMenu(QPoint)));
connect(ui->streamGraph, SIGNAL(mousePress(QMouseEvent*)),
this, SLOT(graphClicked(QMouseEvent*)));
graph_ctx_menu_.addAction(ui->actionSaveGraph);
QStringList header_labels;
for (int i = 0; i < ui->forwardTreeWidget->columnCount(); i++) {
header_labels << ui->forwardTreeWidget->headerItem()->text(i);
}
ui->reverseTreeWidget->setHeaderLabels(header_labels);
memset(&src_fwd_, 0, sizeof(address));
memset(&dst_fwd_, 0, sizeof(address));
memset(&src_rev_, 0, sizeof(address));
memset(&dst_rev_, 0, sizeof(address));
QList<QCheckBox *> graph_cbs = QList<QCheckBox *>()
<< ui->fJitterCheckBox << ui->fDiffCheckBox
<< ui->rJitterCheckBox << ui->rDiffCheckBox;
for (int i = 0; i < num_graphs_; i++) {
QCPGraph *graph = ui->streamGraph->addGraph();
graph->setPen(QPen(ColorUtils::graphColor(i)));
graph->setName(graph_cbs[i]->text());
graphs_ << graph;
graph_cbs[i]->setChecked(true);
graph_cbs[i]->setIcon(StockIcon::colorIcon(ColorUtils::graphColor(i), QPalette::Text));
}
ui->streamGraph->xAxis->setLabel("Arrival Time");
ui->streamGraph->yAxis->setLabel("Value (ms)");
// We keep our temp files open for the lifetime of the dialog. The GTK+
// UI opens and closes at various points.
QString tempname = QString("%1/wireshark_iax2_f").arg(QDir::tempPath());
fwd_tempfile_ = new QTemporaryFile(tempname, this);
fwd_tempfile_->open();
tempname = QString("%1/wireshark_iax2_r").arg(QDir::tempPath());
rev_tempfile_ = new QTemporaryFile(tempname, this);
rev_tempfile_->open();
if (fwd_tempfile_->error() != QFile::NoError || rev_tempfile_->error() != QFile::NoError) {
err_str_ = tr("Unable to save RTP data.");
ui->actionSaveAudio->setEnabled(false);
ui->actionSaveForwardAudio->setEnabled(false);
ui->actionSaveReverseAudio->setEnabled(false);
}
QMenu *save_menu = new QMenu();
save_menu->addAction(ui->actionSaveAudio);
save_menu->addAction(ui->actionSaveForwardAudio);
save_menu->addAction(ui->actionSaveReverseAudio);
save_menu->addSeparator();
save_menu->addAction(ui->actionSaveCsv);
save_menu->addAction(ui->actionSaveForwardCsv);
save_menu->addAction(ui->actionSaveReverseCsv);
save_menu->addSeparator();
save_menu->addAction(ui->actionSaveGraph);
ui->buttonBox->button(QDialogButtonBox::Save)->setMenu(save_menu);
ui->buttonBox->button(QDialogButtonBox::Close)->setDefault(true);
resetStatistics();
updateStatistics(); // Initialize stats if an error occurs
#if 0
//.........这里部分代码省略.........
示例2: createCropedScreenshot
void QLabelMouseTracking::createCropedScreenshot(QMouseEvent *ev)
{
QWidget *mainWidget = this->parentWidget();
mainWidget->hide();
QPixmap pix = QPixmap(); // clear image for low memory situations // on embedded devices.
pix = QPixmap::grabWindow(QApplication::desktop()->winId());
QRect geo = mainWidget->geometry();
QPixmap pixCopy = pix.copy(geo.x(),geo.y(),geo.width(),geo.height());
QString format = "png";
QString pathPix = "d:/MyQT_Project";
QString fileName;
fileName = (QString::number(QDateTime::currentDateTime().toTime_t()));
pixCopy.save(pathPix+ "/" + fileName+".png", format.toLatin1().constData());
// Example %Path% + tesseract.exe croppedImage.png test2 -eng
// I used the escaped backslash, because slash didn't work
// QString foo = "\"d:\\MyQT_Project\\"; // The string contains spaces, that the reason für double qoutes
// foo.append("tesseract.exe");
// QString path = " d:\\MyQT_Project\\";
QString foo = "\"d:\\MyQT_Project\\"; // The string contains spaces, that the reason für double qoutes
foo.append("tesseract.exe");
QString path = "d:\\MyQT_Project\\";
foo.append(path);
foo.append(fileName);
foo.append(".png");
foo.append(path);
foo.append(fileName); // The output file gets automatic a txt-Extension
foo.append(" -eng\"");
//foo = """d:\\MyQT_Project\\tesseract.exe d:\\MyQT_Project\\1402617176.png d:\\MyQT_Project\\1402617176 -eng""";
qDebug()<< foo;
//process->start("cmd /k" + foo);
//process->waitForFinished();
QStringList args;
args.append(path + fileName + ".png");
args.append(path + fileName);
args.append("-eng");
// args.append(path + fileName + ".png");
// args.append(path + fileName);
// args.append(" -eng\"");
qDebug()<< "QStringList" << args;
QProcess *process = new QProcess(this);
// qDebug()<< "!!: " << process->isReadable();
// qDebug()<< "??: " << process->isWritable();
process->start("d:\\MyQT_Project\\tesseract.exe",args,QIODevice::ReadOnly);
process->waitForFinished();
QString txtFile = pathPix+ "/" + fileName+".txt";
qDebug() << "Read txt: " << txtFile;
//QThread *thread = new QThread(this);
// while(true){
// qDebug() << "READ";
// if(file.exists(txtFile))break;
// thread->sleep(1000);
// }
//thread->sleep(1000);
// process->close();
QFile file(txtFile);
QString doc;
if(file.open(QIODevice::ReadOnly | QIODevice::Text)){
QString line;
QTextStream stream(&file);
do{
line = stream.readLine();
doc += line;
qDebug() << "Line " <<line;
}while(! line.isNull());
//The reason for no loop is, that the translation is in one line
}
file.close();
//.........这里部分代码省略.........
示例3: exit
//.........这里部分代码省略.........
windowTitle->setAttribute(Qt::WA_TransparentForMouseEvents);
// Post-initialization header spacing
topLayout->addLayout(systemLayout);
topLayout->addLayout(headerLayout);
topLayout->addSpacing(10);
headerLayout->addSpacing(20);
headerLayout->addWidget(windowTitle);
headerLayout->addSpacing(40);
// Header tabs
libraryTab = new TabLabel(this);
libraryTab = g_tabFactory(libraryTab, "libraryTab", "LIBRARY");
headerLayout->addSpacing(8);
headerLayout->addWidget(libraryTab);
libraryTab->setStyleSheet("font-weight: bold; color: lightgreen;");
storeTab = new TabLabel(this);
storeTab = g_tabFactory(storeTab, "storeTab", " STORE");
headerLayout->addSpacing(8);
headerLayout->addWidget(storeTab);
modsTab = new TabLabel(this);
modsTab = g_tabFactory(modsTab, "modsTab", " MODS");
headerLayout->addSpacing(8);
headerLayout->addWidget(modsTab);
newsTab = new TabLabel(this);
newsTab = g_tabFactory(newsTab, "newsTab", "NEWS");
headerLayout->addSpacing(8);
headerLayout->addWidget(newsTab);
browserTab = new TabLabel(this);
browserTab = g_tabFactory(browserTab, "browserTab", "BROWSER");
headerLayout->addSpacing(8);
headerLayout->addWidget(browserTab);
activeTab = libraryTab;
headerLayout->addStretch();
// System buttons
systemLayout->addStretch();
// Minimize
QPushButton* pushButtonMinimize = new QPushButton("", this);
pushButtonMinimize->setObjectName("pushButtonMinimize");
systemLayout->addWidget(pushButtonMinimize);
QObject::connect(pushButtonMinimize, SIGNAL(clicked()), this, SLOT(pushButtonMinimize()));
// Maximize
QPushButton* pushButtonMaximize = new QPushButton("", this);
pushButtonMaximize->setObjectName("pushButtonMaximize");
systemLayout->addWidget(pushButtonMaximize);
QObject::connect(pushButtonMaximize, SIGNAL(clicked()), this, SLOT(pushButtonMaximize()));
// Close
QPushButton* pushButtonClose = new QPushButton("", this);
pushButtonClose->setObjectName("pushButtonClose");
systemLayout->addWidget(pushButtonClose);
QObject::connect(pushButtonClose, SIGNAL(clicked()), this, SLOT(pushButtonClose()));
// Main panel layout
QGridLayout* mainGridLayout = new QGridLayout();
mainGridLayout->setSpacing(0);
mainGridLayout->setMargin(0);
setLayout(mainGridLayout);
// Central widget
QWidget* centralWidget = new QWidget(this);
centralWidget->setObjectName("centralWidget");
centralWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// Main panel scroll area
QScrollArea* scrollArea = new QScrollArea(this);
scrollArea->setWidgetResizable(true);
scrollArea->setObjectName("mainPanelScrollArea");
scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
// Vertical layout example
QVBoxLayout* verticalLayout = new QVBoxLayout();
verticalLayout->setSpacing(5);
verticalLayout->setMargin(0);
verticalLayout->setAlignment(Qt::AlignHCenter);
verticalLayout->addLayout(topLayout, 1);
verticalLayout->addWidget(stack, 4);
// Connect signals
connect(libraryTab, SIGNAL(clicked()), this, SLOT(setTabLibrary()));
connect(browserTab, SIGNAL(clicked()), this, SLOT(setTabBrowser()));
// Show
centralWidget->setLayout(verticalLayout);
scrollArea->setWidget(centralWidget);
mainGridLayout->addWidget(scrollArea);
}
示例4: updateLegend
//! Update the widget that represents the curve on the legend
void QwtPlotCurve::updateLegend(QwtLegend *legend) const
{
if ( !legend )
return;
QwtPlotItem::updateLegend(legend);
QWidget *widget = legend->find(this);
if ( !widget || !widget->inherits("QwtLegendItem") )
return;
QwtLegendItem *legendItem = (QwtLegendItem *)widget;
#if QT_VERSION < 0x040000
const bool doUpdate = legendItem->isUpdatesEnabled();
#else
const bool doUpdate = legendItem->updatesEnabled();
#endif
legendItem->setUpdatesEnabled(false);
const int policy = legend->displayPolicy();
if (policy == QwtLegend::FixedIdentifier)
{
int mode = legend->identifierMode();
if (mode & QwtLegendItem::ShowLine)
legendItem->setCurvePen(pen());
if (mode & QwtLegendItem::ShowSymbol)
legendItem->setSymbol(symbol());
if (mode & QwtLegendItem::ShowText)
legendItem->setText(title());
else
legendItem->setText(QwtText());
legendItem->setIdentifierMode(mode);
}
else if (policy == QwtLegend::AutoIdentifier)
{
int mode = 0;
if (QwtPlotCurve::NoCurve != style())
{
legendItem->setCurvePen(pen());
mode |= QwtLegendItem::ShowLine;
}
if (QwtSymbol::NoSymbol != symbol().style())
{
legendItem->setSymbol(symbol());
mode |= QwtLegendItem::ShowSymbol;
}
if ( !title().isEmpty() )
{
legendItem->setText(title());
mode |= QwtLegendItem::ShowText;
}
else
{
legendItem->setText(QwtText());
}
legendItem->setIdentifierMode(mode);
}
legendItem->setUpdatesEnabled(doUpdate);
legendItem->update();
}
示例5: QPoint
/*!
Insert a new item for a plot item
\param plotItem Plot item
\param legendItem New legend item
\note The parent of item will be changed to QwtLegend::contentsWidget()
*/
void QwtLegend::insert(const QwtPlotItem *plotItem, QWidget *legendItem)
{
if ( legendItem == NULL || plotItem == NULL )
return;
QWidget *contentsWidget = d_data->view->contentsWidget;
if ( legendItem->parent() != contentsWidget )
{
#if QT_VERSION >= 0x040000
legendItem->setParent(contentsWidget);
#else
legendItem->reparent(contentsWidget, QPoint(0, 0));
#endif
}
legendItem->show();
d_data->map.insert(plotItem, legendItem);
layoutContents();
if ( contentsWidget->layout() )
{
#if QT_VERSION >= 0x040000
contentsWidget->layout()->addWidget(legendItem);
#endif
// set tab focus chain
QWidget *w = NULL;
#if QT_VERSION < 0x040000
QLayoutIterator layoutIterator =
contentsWidget->layout()->iterator();
for ( QLayoutItem *item = layoutIterator.current();
item != 0; item = ++layoutIterator)
{
#else
for (int i = 0; i < contentsWidget->layout()->count(); i++)
{
QLayoutItem *item = contentsWidget->layout()->itemAt(i);
#endif
if ( w && item->widget() )
{
QWidget::setTabOrder(w, item->widget());
w = item->widget();
}
}
}
if ( parentWidget() && parentWidget()->layout() == NULL )
{
/*
updateGeometry() doesn't post LayoutRequest in certain
situations, like when we are hidden. But we want the
parent widget notified, so it can show/hide the legend
depending on its items.
*/
#if QT_VERSION < 0x040000
QApplication::postEvent(parentWidget(),
new QEvent(QEvent::LayoutHint));
#else
QApplication::postEvent(parentWidget(),
new QEvent(QEvent::LayoutRequest));
#endif
}
}
/*!
Find the widget that represents a plot item
\param plotItem Plot item
\return Widget on the legend, or NULL
*/
QWidget *QwtLegend::find(const QwtPlotItem *plotItem) const
{
return d_data->map.find(plotItem);
}
/*!
Find the widget that represents a plot item
\param plotItem Plot item
\return Widget on the legend, or NULL
*/
QwtPlotItem *QwtLegend::find(const QWidget *legendItem) const
{
return d_data->map.find(legendItem);
}
/*!
Find the corresponding item for a plotItem and remove it
from the item list.
//.........这里部分代码省略.........
示例6: event
bool SceneViewer::event(QEvent *e) {
if (e->type() == QEvent::ShortcutOverride || e->type() == QEvent::KeyPress) {
if (!((QKeyEvent *)e)->isAutoRepeat()) {
TApp::instance()->getCurrentTool()->storeTool();
}
}
if (e->type() == QEvent::ShortcutOverride) {
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
if (tool && tool->isEnabled() && tool->getName() == T_Type &&
tool->isActive())
e->accept();
return true;
}
if (e->type() == QEvent::KeyRelease) {
if (!((QKeyEvent *)e)->isAutoRepeat()) {
QWidget *focusWidget = QApplication::focusWidget();
if (focusWidget == 0 ||
QString(focusWidget->metaObject()->className()) == "SceneViewer")
TApp::instance()->getCurrentTool()->restoreTool();
}
}
// discard too frequent move events
static QTime clock;
if (e->type() == QEvent::MouseButtonPress)
clock.start();
else if (e->type() == QEvent::MouseMove) {
if (clock.elapsed() < 10) {
e->accept();
return true;
}
clock.start();
}
/*
switch(e->type())
{
case QEvent::Enter:
qDebug() << "************************** Enter";
break;
case QEvent::Leave:
qDebug() << "************************** Leave";
break;
case QEvent::TabletPress:
qDebug() << "************************** TabletPress" << m_pressure;
break;
case QEvent::TabletMove:
qDebug() << "************************** TabletMove";
break;
case QEvent::TabletRelease:
qDebug() << "************************** TabletRelease";
break;
case QEvent::MouseButtonPress:
qDebug() << "**************************MouseButtonPress" << m_pressure << " "
<< m_tabletEvent;
break;
case QEvent::MouseMove:
qDebug() << "**************************MouseMove" << m_pressure;
break;
case QEvent::MouseButtonRelease:
qDebug() << "**************************MouseButtonRelease";
break;
case QEvent::MouseButtonDblClick:
qDebug() << "============================== MouseButtonDblClick";
break;
}
*/
return QGLWidget::event(e);
}
示例7: QDialog
EditTagDialog::EditTagDialog(Application* app, QWidget* parent)
: QDialog(parent),
ui_(new Ui_EditTagDialog),
app_(app),
album_cover_choice_controller_(new AlbumCoverChoiceController(this)),
loading_(false),
abortRequested_(false),
ignore_edits_(false),
tag_fetcher_(new TagFetcher(this)),
cover_art_id_(0),
cover_art_is_set_(false),
results_dialog_(new TrackSelectionDialog(this)) {
QIcon nocover = IconLoader::Load("nocover", IconLoader::Other);
cover_options_.default_output_image_ =
AlbumCoverLoader::ScaleAndPad(cover_options_,
nocover.pixmap(nocover.availableSizes().last())
.toImage());
connect(app_->album_cover_loader(),
SIGNAL(ImageLoaded(quint64, QImage, QImage)),
SLOT(ArtLoaded(quint64, QImage, QImage)));
connect(tag_fetcher_, SIGNAL(ResultAvailable(Song, SongList)),
results_dialog_, SLOT(FetchTagFinished(Song, SongList)),
Qt::QueuedConnection);
connect(tag_fetcher_, SIGNAL(Progress(Song, QString)), results_dialog_,
SLOT(FetchTagProgress(Song, QString)));
connect(results_dialog_, SIGNAL(SongChosen(Song, Song)),
SLOT(FetchTagSongChosen(Song, Song)));
connect(results_dialog_, SIGNAL(finished(int)), tag_fetcher_, SLOT(Cancel()));
album_cover_choice_controller_->SetApplication(app_);
ui_->setupUi(this);
ui_->splitter->setSizes(QList<int>() << 200 << width() - 200);
ui_->loading_label->hide();
ui_->fetch_tag->setIcon(IconLoader::Load("musicbrainz",
IconLoader::Provider));
// An editable field is one that has a label as a buddy. The label is
// important because it gets turned bold when the field is changed.
for (QLabel* label : findChildren<QLabel*>()) {
QWidget* widget = label->buddy();
if (widget) {
// Store information about the field
fields_ << FieldData(label, widget, widget->objectName());
// Connect the Reset signal
if (dynamic_cast<ExtendedEditor*>(widget)) {
connect(widget, SIGNAL(Reset()), SLOT(ResetField()));
}
// Connect the changed signal (emitted when value is changed
// programmatically or non-programmatically)
if (qobject_cast<QLineEdit*>(widget)) {
connect(widget, SIGNAL(textChanged(QString)), SLOT(FieldValueEdited()));
} else if (qobject_cast<QPlainTextEdit*>(widget)) {
connect(widget, SIGNAL(textChanged()), SLOT(FieldValueEdited()));
} else if (qobject_cast<QSpinBox*>(widget)) {
connect(widget, SIGNAL(valueChanged(int)), SLOT(FieldValueEdited()));
}
}
}
// Set the colour of all the labels on the summary page
const bool light = palette().color(QPalette::Base).value() > 128;
const QColor color = palette().color(QPalette::WindowText);
QPalette summary_label_palette(palette());
summary_label_palette.setColor(
QPalette::WindowText, light ? color.lighter(150) : color.darker(150));
for (QLabel* label : ui_->summary_tab->findChildren<QLabel*>()) {
if (label->property("field_label").toBool()) {
label->setPalette(summary_label_palette);
}
}
// Pretend the summary text is just a label
ui_->summary->setMaximumHeight(ui_->art->height() -
ui_->summary_art_button->height() - 4);
connect(ui_->song_list->selectionModel(),
SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
SLOT(SelectionChanged()));
connect(ui_->button_box, SIGNAL(clicked(QAbstractButton*)),
SLOT(ButtonClicked(QAbstractButton*)));
connect(ui_->rating, SIGNAL(RatingChanged(float)), SLOT(SongRated(float)));
connect(ui_->playcount_reset, SIGNAL(clicked()), SLOT(ResetPlayCounts()));
connect(ui_->fetch_tag, SIGNAL(clicked()), SLOT(FetchTag()));
connect(ui_->abortSaveButton, SIGNAL(clicked()), SLOT(abortSave()));
// Set up the album cover menu
cover_menu_ = new QMenu(this);
QList<QAction*> actions = album_cover_choice_controller_->GetAllActions();
connect(album_cover_choice_controller_->cover_from_file_action(),
SIGNAL(triggered()), this, SLOT(LoadCoverFromFile()));
connect(album_cover_choice_controller_->cover_to_file_action(),
SIGNAL(triggered()), this, SLOT(SaveCoverToFile()));
//.........这里部分代码省略.........
示例8: QWidget
ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* parent )
: QWidget( parent )
, TomahawkUtils::DpiScaler( this )
, ui( new Ui::ArtistInfoWidget )
, m_artist( artist )
{
m_widget = new QWidget;
m_headerWidget = new BasicHeader;
ui->setupUi( m_widget );
{
ui->relatedArtists->setAutoResize( true );
ui->relatedArtists->setAutoFitItems( true );
ui->relatedArtists->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->relatedArtists->setItemWidth( scaledX( 170 ) );
m_relatedModel = new PlayableModel( ui->relatedArtists );
ui->relatedArtists->setPlayableModel( m_relatedModel );
ui->relatedArtists->proxyModel()->sort( -1 );
ui->relatedArtists->setEmptyTip( tr( "Sorry, we could not find any related artists!" ) );
TomahawkStyle::stylePageFrame( ui->relatedArtists );
TomahawkStyle::stylePageFrame( ui->artistFrame );
TomahawkStyle::styleScrollBar( ui->relatedArtists->verticalScrollBar() );
}
{
ui->albums->setAutoResize( true );
ui->albums->setAutoFitItems( false );
ui->albums->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->albums->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->albums->setWrapping( false );
ui->albums->setItemWidth( scaledX( 190 ) );
ui->albums->proxyModel()->setHideDupeItems( true );
ui->albums->delegate()->setWordWrapping( true );
ui->albums->setFixedHeight( ui->albums->itemSize().height() + ui->albums->spacing() * 2 );
m_albumsModel = new PlayableModel( ui->albums );
ui->albums->setPlayableModel( m_albumsModel );
ui->albums->proxyModel()->sort( -1 );
ui->albums->setEmptyTip( tr( "Sorry, we could not find any albums for this artist!" ) );
TomahawkStyle::stylePageFrame( ui->albumFrame );
TomahawkStyle::styleScrollBar( ui->albums->verticalScrollBar() );
TomahawkStyle::styleScrollBar( ui->albums->horizontalScrollBar() );
}
{
ui->topHits->setAutoResize( true );
ui->topHits->setAutoFitItems( false );
ui->topHits->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->topHits->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->topHits->setWrapping( false );
ui->topHits->setItemWidth( scaledX( 140 ) );
ui->topHits->proxyModel()->setHideDupeItems( true );
ui->topHits->delegate()->setWordWrapping( true );
ui->topHits->delegate()->setShowBuyButtons( true );
ui->topHits->setFixedHeight( ui->topHits->itemSize().height() + ui->topHits->spacing() * 2 );
m_topHitsModel = new PlayableModel( ui->topHits );
ui->topHits->setPlayableModel( m_topHitsModel );
ui->topHits->proxyModel()->sort( -1 );
ui->topHits->setEmptyTip( tr( "Sorry, we could not find any top hits for this artist!" ) );
TomahawkStyle::stylePageFrame( ui->trackFrame );
}
{
ui->biography->setObjectName( "biography" );
ui->biography->setContentsMargins( 0, 0, 0, 0 );
ui->biography->page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
ui->biography->page()->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAsNeeded );
ui->biography->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
ui->biography->installEventFilter( this );
TomahawkStyle::stylePageWidget( ui->biography );
TomahawkStyle::stylePageFrame( ui->bioFrame );
connect( ui->biography, SIGNAL( linkClicked( QUrl ) ), SLOT( onBiographyLinkClicked( QUrl ) ) );
QFont f = ui->topHitsMoreLabel->font();
f.setWeight( QFont::Light );
f.setPointSize( TomahawkUtils::defaultFontSize() + 1 );
ui->topHitsMoreLabel->setFont( f );
ui->albumsMoreLabel->setFont( f );
connect( ui->albumsMoreLabel, SIGNAL( clicked() ), SLOT( onAlbumsMoreClicked() ) );
connect( ui->topHitsMoreLabel, SIGNAL( clicked() ), SLOT( onTopHitsMoreClicked() ) );
ui->cover->setFixedSize( scaled( QSize( 384, 384 ) ) );
}
{
m_headerWidget->ui->anchor1Label->setText( tr( "Music" ) );
m_headerWidget->ui->anchor2Label->setText( tr( "Biography" ) );
m_headerWidget->ui->anchor3Label->setText( tr( "Related Artists" ) );
m_headerWidget->ui->anchor1Label->show();
m_headerWidget->ui->anchor2Label->show();
m_headerWidget->ui->anchor3Label->show();
//.........这里部分代码省略.........
示例9: QLabel
void MaterialAssignmentEditorWindow::create_widgets_for_side(
QGridLayout* parent,
const int row_index,
const char* slot_name,
const Side side)
{
parent->addWidget(new QLabel(side == ObjectInstance::FrontSide ? "Front:" : "Back:"), row_index, 0, Qt::AlignRight);
QHBoxLayout* layout = new QHBoxLayout();
layout->setSpacing(6);
QWidget* group = new QWidget();
group->setLayout(new QHBoxLayout());
group->layout()->setContentsMargins(0, 0, 0, 0);
QComboBox* combo_box = 0;
if (side == ObjectInstance::BackSide)
{
combo_box = new QComboBox();
combo_box->addItem("Same As Front", "same");
combo_box->addItem("None", "none");
combo_box->addItem("Enabled", "enabled");
combo_box->setCurrentIndex(-1);
layout->addWidget(combo_box);
new MouseWheelFocusEventFilter(combo_box);
m_mode_combo_to_widget_group[combo_box] = group;
const StringDictionary& front_mappings = m_object_instance.get_front_material_mappings();
const StringDictionary& back_mappings = m_object_instance.get_back_material_mappings();
if (!back_mappings.exist(slot_name))
{
combo_box->setCurrentIndex(combo_box->findData("none"));
group->setEnabled(false);
}
else if (front_mappings.exist(slot_name) &&
front_mappings.get<string>(slot_name) == back_mappings.get<string>(slot_name))
{
combo_box->setCurrentIndex(combo_box->findData("same"));
group->setEnabled(false);
}
else
{
combo_box->setCurrentIndex(combo_box->findData("enabled"));
group->setEnabled(true);
}
connect(
combo_box, SIGNAL(currentIndexChanged(int)),
SLOT(slot_change_back_material_mode(int)));
}
QLineEdit* line_edit = new QLineEdit();
group->layout()->addWidget(line_edit);
const StringDictionary& mappings =
side == ObjectInstance::FrontSide
? m_object_instance.get_front_material_mappings()
: m_object_instance.get_back_material_mappings();
if (m_object->get_material_slot_count() > 0)
{
if (mappings.exist(slot_name))
line_edit->setText(mappings.get<QString>(slot_name));
}
else if (!mappings.empty())
{
line_edit->setText(mappings.begin().value<QString>());
}
connect(line_edit, SIGNAL(returnPressed()), SLOT(slot_apply()));
QPushButton* browse_button = new QPushButton("Browse");
browse_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
group->layout()->addWidget(browse_button);
SlotInfo& slot_info = m_slot_infos[browse_button];
slot_info.m_slot_name = slot_name;
slot_info.m_side = side;
slot_info.m_combo_box = combo_box;
slot_info.m_line_edit = line_edit;
connect(
browse_button, SIGNAL(clicked()),
SLOT(slot_open_entity_browser()));
layout->addWidget(group);
parent->addLayout(layout, row_index, 1);
}
示例10: QMainWindow
//! [0]
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), completer(0), lineEdit(0)
{
createMenu();
QWidget *centralWidget = new QWidget;
QLabel *modelLabel = new QLabel;
modelLabel->setText(tr("Model"));
modelCombo = new QComboBox;
modelCombo->addItem(tr("QDirModel"));
modelCombo->addItem(tr("QDirModel that shows full path"));
modelCombo->addItem(tr("Country list"));
modelCombo->addItem(tr("Word list"));
modelCombo->setCurrentIndex(0);
QLabel *modeLabel = new QLabel;
modeLabel->setText(tr("Completion Mode"));
modeCombo = new QComboBox;
modeCombo->addItem(tr("Inline"));
modeCombo->addItem(tr("Filtered Popup"));
modeCombo->addItem(tr("Unfiltered Popup"));
modeCombo->setCurrentIndex(1);
QLabel *caseLabel = new QLabel;
caseLabel->setText(tr("Case Sensitivity"));
caseCombo = new QComboBox;
caseCombo->addItem(tr("Case Insensitive"));
caseCombo->addItem(tr("Case Sensitive"));
caseCombo->setCurrentIndex(0);
//! [0]
//! [1]
QLabel *maxVisibleLabel = new QLabel;
maxVisibleLabel->setText(tr("Max Visible Items"));
maxVisibleSpinBox = new QSpinBox;
maxVisibleSpinBox->setRange(3,25);
maxVisibleSpinBox->setValue(10);
wrapCheckBox = new QCheckBox;
wrapCheckBox->setText(tr("Wrap around completions"));
wrapCheckBox->setChecked(true);
//! [1]
//! [2]
contentsLabel = new QLabel;
contentsLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
connect(modelCombo, SIGNAL(activated(int)), this, SLOT(changeModel()));
connect(modeCombo, SIGNAL(activated(int)), this, SLOT(changeMode(int)));
connect(caseCombo, SIGNAL(activated(int)), this, SLOT(changeCase(int)));
connect(maxVisibleSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeMaxVisible(int)));
//! [2]
//! [3]
lineEdit = new QLineEdit;
QGridLayout *layout = new QGridLayout;
layout->addWidget(modelLabel, 0, 0); layout->addWidget(modelCombo, 0, 1);
layout->addWidget(modeLabel, 1, 0); layout->addWidget(modeCombo, 1, 1);
layout->addWidget(caseLabel, 2, 0); layout->addWidget(caseCombo, 2, 1);
layout->addWidget(maxVisibleLabel, 3, 0); layout->addWidget(maxVisibleSpinBox, 3, 1);
layout->addWidget(wrapCheckBox, 4, 0);
layout->addWidget(contentsLabel, 5, 0, 1, 2);
layout->addWidget(lineEdit, 6, 0, 1, 2);
centralWidget->setLayout(layout);
setCentralWidget(centralWidget);
changeModel();
setWindowTitle(tr("Completer"));
lineEdit->setFocus();
}
示例11: QFETCH
void tst_QColumnView::scrollTo()
{
QFETCH(bool, reverse);
QFETCH(bool, giveFocus);
if (reverse)
qApp->setLayoutDirection(Qt::RightToLeft);
ColumnView view;
view.resize(200, 200);
view.show();
view.scrollTo(QModelIndex(), QAbstractItemView::EnsureVisible);
QCOMPARE(view.HorizontalOffset(), 0);
TreeModel model;
view.setModel(&model);
view.scrollTo(QModelIndex(), QAbstractItemView::EnsureVisible);
QModelIndex home;
home = model.index(0, 0, home);
home = model.index(0, 0, home);
home = model.index(0, 0, home);
view.scrollTo(home, QAbstractItemView::EnsureVisible);
QModelIndex homeFile = model.index(0, 0, home);
view.setRootIndex(home);
QModelIndex index = model.index(0, 0, home);
view.scrollTo(index, QAbstractItemView::EnsureVisible);
QCOMPARE(view.HorizontalOffset(), 0);
// Embedded requires that at least one widget have focus
QWidget w;
w.show();
if (giveFocus)
view.setFocus(Qt::OtherFocusReason);
else
view.clearFocus();
QTRY_COMPARE(view.hasFocus(), giveFocus);
// scroll to the right
int level = 0;
int last = view.HorizontalOffset();
while(model.hasChildren(index) && level < 5) {
view.setCurrentIndex(index);
QTest::qWait(ANIMATION_DELAY);
view.scrollTo(index, QAbstractItemView::EnsureVisible);
QTest::qWait(ANIMATION_DELAY);
qApp->processEvents();
index = model.index(0, 0, index);
level++;
if (level >= 2) {
if (!reverse) {
QTRY_VERIFY(view.HorizontalOffset() < 0);
QTRY_VERIFY(last > view.HorizontalOffset());
} else {
QTRY_VERIFY(view.HorizontalOffset() > 0);
QTRY_VERIFY(last < view.HorizontalOffset());
}
}
last = view.HorizontalOffset();
}
// scroll to the left
int start = level;
while(index.parent().isValid() && index != view.rootIndex()) {
view.setCurrentIndex(index);
QTest::qWait(ANIMATION_DELAY);
view.scrollTo(index, QAbstractItemView::EnsureVisible);
index = index.parent();
if (start != level) {
if (!reverse)
QTRY_VERIFY(last < view.HorizontalOffset());
else
QTRY_VERIFY(last > view.HorizontalOffset());
}
level--;
last = view.HorizontalOffset();
}
// It shouldn't automatically steal focus if it doesn't have it
QTRY_COMPARE(view.hasFocus(), giveFocus);
// Try scrolling to something that is above the root index
home = model.index(0, 0, QModelIndex());
QModelIndex temp = model.index(1, 0, home);
home = model.index(0, 0, home);
home = model.index(0, 0, home);
view.setRootIndex(home);
view.scrollTo(model.index(0, 0, home));
QTest::qWait(ANIMATION_DELAY);
view.scrollTo(temp);
}
示例12: KraftViewBase
KraftView::KraftView(QWidget *parent) :
KraftViewBase( parent ),
mHelpLabel( 0 ), mRememberAmount( -1 ), mModified( false )
{
setCaption( i18n("Document" ) );
setModal( false );
setButtons( KDialog::Ok | KDialog::Cancel );
m_type = ReadWrite;
QWidget *w = new QWidget( this );
QVBoxLayout *vLayoutGlobal = new QVBoxLayout;
w->setLayout( vLayoutGlobal );
setMainWidget( w );
mDetailHeader = new QLabel;
mDetailHeader->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) );
mDetailHeader->setFrameStyle( QFrame::Box + QFrame::Plain );
mDetailHeader->setLineWidth( 1 );
mDetailHeader->setAutoFillBackground(true);
mAddressProvider = new AddressProvider( this );
connect( mAddressProvider, SIGNAL(addresseeFound( const QString&, const KABC::Addressee& )),
this, SLOT( slotAddresseeFound( const QString&, const KABC::Addressee& )));
QPalette palette;
palette.setColor(mDetailHeader->backgroundRole(), QColor( "darkBlue" ));
palette.setColor(mDetailHeader->foregroundRole(), QColor( "white "));
mDetailHeader->setPalette( palette );
mDetailHeader->setTextFormat( Qt::PlainText );
mDetailHeader->setFixedHeight( 40 ); // FIXME
QFont f = mDetailHeader->font();
f.setPointSize( qRound( 1.4 * f.pointSize() ) );
f.setBold( true );
mDetailHeader->setFont( f );
vLayoutGlobal->addWidget( mDetailHeader );
mCSplit = new QSplitter( w );
vLayoutGlobal->addWidget( mCSplit );
mViewStack = new QStackedWidget;
mCSplit->addWidget( mViewStack );
kDebug() << "mViewSTack height is " << mViewStack->height() << endl;
mAssistant = new DocAssistant( mCSplit );
mCSplit->addWidget( mAssistant );
/* catalog template selection signal */
connect( mAssistant, SIGNAL( templatesToDocument(Katalog*,CatalogTemplateList) ),
this, SLOT( slotAddItems( Katalog*, CatalogTemplateList ) ) );
/* signal to toggle the visibility of the template section in the assistant */
connect( mAssistant, SIGNAL( toggleShowTemplates( bool ) ),
this, SLOT( slotShowTemplates( bool ) ) );
/* signal that brings a new address to the document */
connect( mAssistant, SIGNAL( addressTemplate( const Addressee& ) ),
this, SLOT( slotNewAddress( const Addressee& ) ) );
connect( mAssistant, SIGNAL( headerTextTemplate( const QString& ) ),
this, SLOT( slotNewHeaderText( const QString& ) ) );
connect( mAssistant, SIGNAL( footerTextTemplate( const QString& ) ),
this, SLOT( slotNewFooterText( const QString& ) ) );
if ( KraftSettings::self()->docViewSplitter().count() == 2 ) {
mCSplit->setSizes( KraftSettings::self()->docViewSplitter() );
}
connect( mAssistant, SIGNAL( selectPage( int ) ),
this, SLOT( slotSwitchToPage( int ) ) );
QSize size = KraftSettings::self()->docViewSize();
if ( !size.isEmpty() ) resize( size );
QPoint pos = KraftSettings::self()->docViewPosition();
if ( !pos.isNull() ) move( pos );
mAssistant->slotSelectDocPart( KraftDoc::Header );
setupMappers();
}
示例13: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
//ui->setupUi(this);
setFixedHeight(768); //1024
setFixedWidth(768);
//Define page structure
QWidget * page = new QWidget(this);
page->setFixedWidth(this->width());
page->setFixedHeight(this->height());
page->setStyleSheet("background-color:white;");
QVBoxLayout * pageLayout = new QVBoxLayout();
//Define the fixed header
QWidget * header = new QWidget(page);
header->setFixedWidth(page->width());
QGridLayout * headerLayout = new QGridLayout();
headerLayout->setHorizontalSpacing(2);
headerLayout->setVerticalSpacing(2);
QLabel * numTable = new QLabel();
QPixmap numTableIm(":/Images/images/NumTable.png");
// numTable->setStyleSheet("margin-right: 5px");
numTable->setPixmap(numTableIm);
numTable->setFixedSize(numTableIm.rect().size());
QLabel * banner = new QLabel(header);
QPixmap bannerIm(":/Images/images/Banner.png");
banner->setPixmap(bannerIm);
banner->setFixedSize(bannerIm.rect().size());
QPushButton * pain = new QPushButton("");
QPixmap painIm(":/Images/images/Pain.png");
QIcon painIcon(painIm);
pain->setIcon(painIcon);
pain->setIconSize(painIm.rect().size());
pain->setFixedSize(painIm.rect().size());
QPushButton * eau = new QPushButton("");
QPixmap eauIm(":/Images/images/eau.png");
QIcon eauIcon(eauIm);
eau->setIcon(eauIcon);
eau->setIconSize(eauIm.rect().size());
eau->setFixedSize(eauIm.rect().size());
QPushButton * serveur = new QPushButton("");
QPixmap serveurIm(":/Images/images/Serveur.png");
QIcon serveurIcon(serveurIm);
serveur->setIcon(serveurIcon);
serveur->setIconSize(serveurIm.rect().size());
serveur->setFixedSize(serveurIm.rect().size());
headerLayout->addWidget(numTable, 0, 0, 2, 0);
headerLayout->addWidget(banner, 0, 1, 2, 1);
headerLayout->addWidget(serveur,0, 2, 2, 2);
headerLayout->addWidget(pain, 0, 3);
headerLayout->addWidget(eau, 1, 3);
header->setLayout(headerLayout);
//Define the widget containing all the meals (Tabs)
QTabWidget * repasFrame = new QTabWidget(page);
//For one Meal, define the widget containing all the bands
QWidget * area = new QWidget(repasFrame);
QScrollArea * sArea = new QScrollArea(area);
QPalette * palette = new QPalette();
palette->setColor(QPalette::Background, Qt::white);
sArea->setPalette(*palette);
sArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
sArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
sArea->setFixedWidth(page->width() -20);
sArea->setFixedHeight(page->height() - header->height() - 125);
bands = new QWidget();
bands->setFixedWidth(page->width() -25);
// bands->setMinimumHeight(page->height() - header->height() - 125);
bands->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
bandsLayout = new QVBoxLayout(bands);
Headband* menus = HeadbandFactory::buildMenus(bands);
bandList.append(menus);
bandsLayout->addWidget(menus);
usefulLabel = new QLabel();
bandsLayout->addWidget(usefulLabel);
bands->setLayout(bandsLayout);
sArea->setWidget(bands);
repasFrame->setFixedWidth(page->width());
repasFrame->setFixedHeight(page->height() - header->height());
repasFrame->addTab(area, "Repas 1");
repasFrame->addTab(new QLabel(), "+");
//Define the confirmation button
//.........这里部分代码省略.........
示例14: initFirstWidget
void MusicWebDJRadioInfoWidget::createLabels()
{
initFirstWidget();
m_container->show();
layout()->removeWidget(m_mainWindow);
QScrollArea *scrollArea = new QScrollArea(this);
scrollArea->verticalScrollBar()->setStyleSheet(MusicUIObject::MScrollBarStyle01);
scrollArea->setWidgetResizable(true);
scrollArea->setFrameShape(QFrame::NoFrame);
scrollArea->setAlignment(Qt::AlignLeft);
scrollArea->setWidget(m_mainWindow);
layout()->addWidget(scrollArea);
QWidget *function = new QWidget(m_mainWindow);
function->setStyleSheet(MusicUIObject::MCheckBoxStyle01 + MusicUIObject::MPushButtonStyle03);
QVBoxLayout *grid = new QVBoxLayout(function);
QWidget *firstTopFuncWidget = new QWidget(function);
QHBoxLayout *firstTopFuncLayout = new QHBoxLayout(firstTopFuncWidget);
QLabel *firstLabel = new QLabel(function);
firstLabel->setText(tr("<font color=#158FE1> DJRadio > %1 </font>").arg(m_currentPlaylistItem.m_name));
QPushButton *backButton = new QPushButton(tr("Back"));
backButton->setFixedSize(90, 30);
backButton->setStyleSheet(MusicUIObject::MPushButtonStyle03);
backButton->setCursor(QCursor(Qt::PointingHandCursor));
connect(backButton, SIGNAL(clicked()), this, SIGNAL(backToMainMenu()));
firstTopFuncLayout->addWidget(firstLabel);
firstTopFuncLayout->addWidget(backButton);
grid->addWidget(firstTopFuncWidget);
////////////////////////////////////////////////////////////////////////////
QWidget *topFuncWidget = new QWidget(function);
QHBoxLayout *topFuncLayout = new QHBoxLayout(topFuncWidget);
m_iconLabel = new QLabel(topFuncWidget);
m_iconLabel->setPixmap(QPixmap(":/image/lb_warning").scaled(180, 180));
m_iconLabel->setFixedSize(210, 180);
////////////////////////////////////////////////////////////////////////////
QWidget *topLineWidget = new QWidget(topFuncWidget);
QVBoxLayout *topLineLayout = new QVBoxLayout(topLineWidget);
topLineLayout->setContentsMargins(10, 5, 5, 0);
QLabel *nameLabel = new QLabel(topLineWidget);
QFont nameFont = nameLabel->font();
nameFont.setPixelSize(20);
nameLabel->setFont(nameFont);
nameLabel->setStyleSheet(MusicUIObject::MFontStyle01);
nameLabel->setText("-");
QLabel *singerLabel = new QLabel(topLineWidget);
singerLabel->setStyleSheet(MusicUIObject::MColorStyle04 + MusicUIObject::MFontStyle03);
singerLabel->setText("-");
QLabel *playCountLabel = new QLabel(topLineWidget);
playCountLabel->setStyleSheet(MusicUIObject::MColorStyle04 + MusicUIObject::MFontStyle03);
QLabel *updateTimeLabel = new QLabel(topLineWidget);
updateTimeLabel->setStyleSheet(MusicUIObject::MColorStyle04 + MusicUIObject::MFontStyle03);
updateTimeLabel->setText("-");
topLineLayout->addWidget(nameLabel);
topLineLayout->addWidget(singerLabel);
topLineLayout->addWidget(playCountLabel);
topLineLayout->addWidget(updateTimeLabel);
topLineWidget->setLayout(topLineLayout);
topFuncLayout->addWidget(m_iconLabel);
topFuncLayout->addWidget(topLineWidget);
topFuncWidget->setLayout(topFuncLayout);
grid->addWidget(topFuncWidget);
////////////////////////////////////////////////////////////////////////////
QWidget *functionWidget = new QWidget(this);
functionWidget->setStyleSheet(MusicUIObject::MPushButtonStyle03);
QHBoxLayout *hlayout = new QHBoxLayout(functionWidget);
m_songButton = new QPushButton(functionWidget);
m_songButton->setText(tr("songItems"));
m_songButton->setFixedSize(100, 25);
m_songButton->setCursor(QCursor(Qt::PointingHandCursor));
hlayout->addWidget(m_songButton);
hlayout->addStretch(1);
functionWidget->setLayout(hlayout);
QButtonGroup *group = new QButtonGroup(this);
group->addButton(m_songButton, 0);
connect(group, SIGNAL(buttonClicked(int)), m_container, SLOT(setCurrentIndex(int)));
#ifdef Q_OS_UNIX
m_songButton->setFocusPolicy(Qt::NoFocus);
#endif
grid->addWidget(functionWidget);
//////////////////////////////////////////////////////////////////////
grid->addWidget(m_container);
grid->addStretch(1);
function->setLayout(grid);
m_mainWindow->layout()->addWidget(function);
m_resizeWidgets << nameLabel << singerLabel << playCountLabel << updateTimeLabel;
}
示例15: QVBoxLayout
void JabberCreateAccountWidget::createGui(bool showButtons)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QWidget *formWidget = new QWidget(this);
mainLayout->addWidget(formWidget);
QFormLayout *layout = new QFormLayout(formWidget);
QWidget *jidWidget = new QWidget(this);
QGridLayout *jidLayout = new QGridLayout(jidWidget);
jidLayout->setSpacing(0);
jidLayout->setMargin(0);
jidLayout->setColumnStretch(0, 2);
jidLayout->setColumnStretch(2, 2);
Username = new QLineEdit(this);
connect(Username, SIGNAL(textEdited(QString)), this, SLOT(dataChanged()));
jidLayout->addWidget(Username);
QLabel *atLabel = new QLabel("@", this);
jidLayout->addWidget(atLabel, 0, 1);
Domain = new QComboBox();
Domain->setEditable(true);
connect(Domain, SIGNAL(currentIndexChanged(QString)), this, SLOT(dataChanged()));
connect(Domain, SIGNAL(editTextChanged(QString)), this, SLOT(dataChanged()));
jidLayout->addWidget(Domain, 0, 2);
layout->addRow(tr("Username") + ':', jidWidget);
NewPassword = new QLineEdit(this);
connect(NewPassword, SIGNAL(textEdited(const QString &)), this, SLOT(dataChanged()));
NewPassword->setEchoMode(QLineEdit::Password);
layout->addRow(tr("Password") + ':', NewPassword);
ReNewPassword = new QLineEdit(this);
connect(ReNewPassword, SIGNAL(textEdited(const QString &)), this, SLOT(dataChanged()));
ReNewPassword->setEchoMode(QLineEdit::Password);
layout->addRow(tr("Retype Password") + ':', ReNewPassword);
RememberPassword = new QCheckBox(tr("Remember password"), this);
layout->addWidget(RememberPassword);
IdentityCombo = new IdentitiesComboBox(true, this);
connect(IdentityCombo, SIGNAL(identityChanged(Identity)), this, SLOT(dataChanged()));
layout->addRow(tr("Account Identity") + ':', IdentityCombo);
QLabel *infoLabel = new QLabel(tr("<font size='-1'><i>Select or enter the identity that will be associated with this account.</i></font>"), this);
infoLabel->setWordWrap(true);
infoLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
infoLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
layout->addRow(0, infoLabel);
QLabel *moreOptionsLabel = new QLabel;
moreOptionsLabel->setText(tr("More options:"));
ExpandConnectionOptionsButton = new QPushButton(">");
ExpandConnectionOptionsButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
connect(ExpandConnectionOptionsButton, SIGNAL(clicked()), this, SLOT(connectionOptionsChanged()));
QWidget *moreOptions = new QWidget;
QHBoxLayout *moreOptionsLayout = new QHBoxLayout(moreOptions);
moreOptionsLayout->addWidget(moreOptionsLabel);
moreOptionsLayout->addWidget(ExpandConnectionOptionsButton);
moreOptionsLayout->setAlignment(ExpandConnectionOptionsButton, Qt::AlignLeft);
moreOptionsLayout->insertStretch(-1);
moreOptions->setLayout(moreOptionsLayout);
mainLayout->addWidget(moreOptions);
OptionsWidget = new QWidget(this);
QHBoxLayout *optionsLayout = new QHBoxLayout((OptionsWidget));
QGroupBox *connectionOptions = new QGroupBox(OptionsWidget);
optionsLayout->addWidget(connectionOptions);
connectionOptions->setTitle(tr("Connection settings"));
QVBoxLayout *vboxLayout2 = new QVBoxLayout(connectionOptions);
vboxLayout2->setSpacing(6);
vboxLayout2->setMargin(9);
CustomHostPort = new QCheckBox(connectionOptions);
CustomHostPort->setText(tr("Manually Specify Server Host/Port") + ':');
vboxLayout2->addWidget(CustomHostPort);
connect(CustomHostPort, SIGNAL(toggled(bool)), SLOT(hostToggled(bool)));
HostPortLayout = new QHBoxLayout();
HostPortLayout->setSpacing(6);
HostPortLayout->setMargin(0);
CustomHostLabel = new QLabel(connectionOptions);
CustomHostLabel->setText(tr("Host") + ':');
HostPortLayout->addWidget(CustomHostLabel);
CustomHost = new QLineEdit(connectionOptions);
HostPortLayout->addWidget(CustomHost);
CustomPortLabel = new QLabel(connectionOptions);
CustomPortLabel->setText(tr("Port") + ':');
HostPortLayout->addWidget(CustomPortLabel);
//.........这里部分代码省略.........