本文整理汇总了C++中QLabel::setFixedWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::setFixedWidth方法的具体用法?C++ QLabel::setFixedWidth怎么用?C++ QLabel::setFixedWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::setFixedWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pixmap
SketchMainHelpPrivate::SketchMainHelpPrivate (
const QString &viewString,
const QString &htmlText,
SketchMainHelp *parent)
: QFrame()
{
setObjectName("sketchMainHelp"+viewString);
m_parent = parent;
QFrame *main = new QFrame(this);
QHBoxLayout *mainLayout = new QHBoxLayout(main);
QLabel *imageLabel = new QLabel(this);
QLabel *imageLabelAux = new QLabel(imageLabel);
imageLabelAux->setObjectName(QString("inviewHelpImage%1").arg(viewString));
QPixmap pixmap(QString(":/resources/images/helpImage%1.png").arg(viewString));
imageLabelAux->setPixmap(pixmap);
imageLabel->setFixedWidth(pixmap.width());
imageLabel->setFixedHeight(pixmap.height());
imageLabelAux->setFixedWidth(pixmap.width());
imageLabelAux->setFixedHeight(pixmap.height());
ExpandingLabel *textLabel = new ExpandingLabel(this);
textLabel->setLabelText(htmlText);
textLabel->setFixedWidth(430 - 41 - pixmap.width());
textLabel->allTextVisible();
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
textLabel->setToolTip("");
textLabel->setAlignment(Qt::AlignLeft);
mainLayout->setSpacing(6);
mainLayout->setMargin(2);
mainLayout->addWidget(imageLabel);
mainLayout->addWidget(textLabel);
setFixedWidth(430);
QVBoxLayout *layout = new QVBoxLayout(this);
m_closeButton = new SketchMainHelpCloseButton(viewString,this);
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(doClose()));
QFrame *bottomMargin = new QFrame(this);
bottomMargin->setFixedHeight(m_closeButton->height());
layout->addWidget(m_closeButton);
layout->addWidget(main);
layout->addWidget(bottomMargin);
layout->setSpacing(0);
layout->setMargin(2);
m_shouldGetTransparent = false;
//m_closeButton->doHide();
QFile styleSheet(":/resources/styles/inviewhelp.qss");
if (!styleSheet.open(QIODevice::ReadOnly)) {
qWarning("Unable to open :/resources/styles/inviewhelp.qss");
} else {
setStyleSheet(styleSheet.readAll());
}
}
示例2: __initializeLayoutHorizontal
QLayout* ColorDlg::__initializeLayoutHorizontal() {
QGridLayout* pL = new QGridLayout( this, 6, 5, 5, 2);
pL->addWidget(new QLabel(tr( "Line"), this), 0, 0);
pL->addWidget(pCB_Line, 0, 1);
pL->addWidget(new QLabel(tr( "Back"), this), 1, 0);
pL->addWidget(pCB_BGColor, 1, 1);
pL->addWidget(new QLabel(tr( "BallLine"), this), 2, 0);
pL->addWidget(pCB_BallLine, 2, 1);
QLabel* pTL;
pTL = new QLabel(this);
pTL->setFixedWidth(30);
pL->addWidget(pTL, 0, 2);
pL->addMultiCellWidget(pRB_UseColorList, 0, 0, 3, 4);
pL->addMultiCellWidget(pRB_UseSameColor, 1, 1, 3, 4);
pTL = new QLabel(this);
pTL->setFixedWidth(60);
pL->addWidget(pTL, 2, 3);
pL->addWidget(pCB_BallColor, 2, 4);
pL->addMultiCellWidget( pOK, 5, 5, 0, 4 );
return pL;
}
示例3: QMdiSubWindow
/*!
\brief Constructor.
Creates a new instance of ProjectWindow.
\param pro project data to show, not null.
\param parent parent widgets of this window, default value is 0.
*/
Ui::ProjectWindow::ProjectWindow(Core::Project *pro, QWidget *parent /* = 0 */)
: QMdiSubWindow(parent),
project(pro)
{
// entry conditions
Q_CHECK_PTR(pro);
setAttribute(Qt::WA_DeleteOnClose);
setWindowIcon(QIcon(":/proj"));
setWindowTitle(project->name());
setMinimumSize(200, 200);
// project view, the main widget
view = new ProjectView(this);
scene = new ProjectScene(project, this);
view->setScene(scene);
view->setSceneRect(0, 0, project->width(), project->height());
QScrollArea* centerPanel = new QScrollArea(this);
centerPanel->viewport()->setStyleSheet(QString("background-color:#C0C0C0"));
centerPanel->setAlignment(Qt::AlignCenter);
centerPanel->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
centerPanel->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
centerPanel->setWidget(view);
// status bar
statusBar = new QWidget(this);
QHBoxLayout *statusLayout = new QHBoxLayout(statusBar);
statusLayout->setMargin(0);
statusBar->setLayout(statusLayout);
QLineEdit* percentInput = new QLineEdit(statusBar);
percentInput->setText("100");
percentInput->setFixedSize(40, 18);
QLabel *msgLabel = new QLabel(statusBar);
msgLabel->setText("%");
msgLabel->setFixedWidth(8);
QPushButton *gridButton = new QPushButton(statusBar);
gridButton->setText("#");
gridButton->setCheckable(true);
gridButton->setFixedSize(20, 18);
QLabel *ctrlLabel = new QLabel(statusBar);
ctrlLabel->setFixedWidth(qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent) - 6);
statusLayout->addWidget(percentInput);
statusLayout->addWidget(msgLabel);
statusLayout->addWidget(gridButton);
statusLayout->addWidget(centerPanel->horizontalScrollBar(), 100);
statusLayout->addWidget(ctrlLabel);
QWidget *mainPanel = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
mainLayout->addWidget(centerPanel);
mainLayout->addWidget(statusBar);
mainPanel->setLayout(mainLayout);
setWidget(mainPanel);
connect(gridButton, SIGNAL(clicked(bool)), scene, SLOT(showGrid(bool)));
connect(appCtx->mainWindow(), SIGNAL(antialiasingChanged(bool)), scene, SLOT(setAntialiasing(bool)));
}
示例4: labelFont
//
//
// CButDlg Class
//
// Provide a dialog to add/edit a filter button to the MsgDialog
//
CButDlg::CButDlg(QWidget *parent, QString name, MyButton *but)
: QDialog(parent, name, TRUE)
{
QBoxLayout *topLayout = new QVBoxLayout(this);
QBoxLayout *row1Layout = new QHBoxLayout(topLayout);
QBoxLayout *row2Layout = new QHBoxLayout(topLayout);
QFont labelFont(font());
labelFont.setBold(true);
QLabel *nameLabel = new QLabel ("Name", this);
nameLabel->setFont(labelFont);
nameLabel->setFixedHeight(nameLabel->sizeHint().height());
nameLabel->setFixedWidth(80);
nameLabel->setAlignment(QLabel::AlignLeft|QLabel::AlignVCenter);
row1Layout->addWidget(nameLabel);
QLineEdit *nameEdit = new QLineEdit (this, "Name");
nameEdit->setText(but->text());
nameEdit->setFont(labelFont);
nameEdit->setFixedHeight(nameEdit->sizeHint().height());
nameEdit->setFixedWidth(150);
row1Layout->addWidget(nameEdit);
QLabel *filterLabel = new QLabel ("Filter", this);
filterLabel->setFont(labelFont);
filterLabel->setFixedHeight(filterLabel->sizeHint().height());
filterLabel->setFixedWidth(80);
filterLabel->setAlignment(QLabel::AlignLeft|QLabel::AlignVCenter);
row2Layout->addWidget(filterLabel);
QLineEdit *filterEdit = new QLineEdit (this, "Filter");
filterEdit->setText(but->filter());
filterEdit->setFont(labelFont);
filterEdit->setFixedHeight(filterEdit->sizeHint().height());
filterEdit->setFixedWidth(150);
row2Layout->addWidget(filterEdit);
QPushButton *ok = new QPushButton("OK", this);
ok->setFixedWidth(30);
ok->setFixedHeight(30);
topLayout->addWidget(ok, 0, AlignCenter);
// connect sigs
connect(nameEdit, SIGNAL(textChanged(const QString &)),
but, SLOT(setText(const QString &)));
connect(filterEdit, SIGNAL(textChanged(const QString &)),
but, SLOT(setFilter(const QString &)));
connect(ok, SIGNAL(clicked()), SLOT(accept()));
setMaximumSize(QSize(sizeHint()));
}
示例5: Initialize
// TODO(xyz): ugh, a lot of copypasta below, perhaps this could be done
// in a nice way?
void SocketsColorsFilter::Initialize(QLayout *parent, const char* caption) {
QWidget *group = new QWidget;
QHBoxLayout *layout = new QHBoxLayout;
layout->setMargin(0);
QLabel *label = new QLabel(caption);
label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
textbox_r_ = new QLineEdit;
textbox_r_->setPlaceholderText("R");
textbox_g_ = new QLineEdit;
textbox_g_->setPlaceholderText("G");
textbox_b_ = new QLineEdit;
textbox_b_->setPlaceholderText("B");
layout->addWidget(label);
layout->addWidget(textbox_r_);
layout->addWidget(textbox_g_);
layout->addWidget(textbox_b_);
group->setLayout(layout);
parent->addWidget(group);
textbox_r_->setFixedWidth(Util::TextWidth(TextWidthId::WIDTH_RGB));
textbox_g_->setFixedWidth(Util::TextWidth(TextWidthId::WIDTH_RGB));
textbox_b_->setFixedWidth(Util::TextWidth(TextWidthId::WIDTH_RGB));
label->setFixedWidth(Util::TextWidth(TextWidthId::WIDTH_LABEL));
QObject::connect(textbox_r_, SIGNAL(textEdited(const QString&)),
parent->parentWidget()->window(), SLOT(OnSearchFormChange()));
QObject::connect(textbox_g_, SIGNAL(textEdited(const QString&)),
parent->parentWidget()->window(), SLOT(OnSearchFormChange()));
QObject::connect(textbox_b_, SIGNAL(textEdited(const QString&)),
parent->parentWidget()->window(), SLOT(OnSearchFormChange()));
}
示例6: QLabel
void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
{
QLabel *label = new QLabel("Qt uses standard C++, but makes extensive use of the C pre-processor to enrich the language. Qt can also be used in several other programming languages via language bindings. It runs on all major platforms, and has extensive internationalization support. Non-GUI features include SQL database access, XML parsing, thread management, network support and a unified cross-platform API for file handling.");
label->setWordWrap(true);
label->setFixedWidth(200);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(label);
layout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding));
QWidget widget;
widget.setLayout(layout);
widget.show();
QTest::qWaitForWindowShown(&widget);
int height = label->height();
QRect g = widget.geometry();
g.setWidth(600);
widget.setGeometry(g);
QTest::qWait(50);
QCOMPARE(label->height(), height);
}
示例7: display
void CGraphicBuildingTile::display(QList<QString> _toDisplay)
{
QDialog* infoDialog = new QDialog;//(dynamic_cast<QWidget*>(this->parent()));
QVBoxLayout* newLayout = new QVBoxLayout();
int q=0;
QScrollArea* scrolArea = new QScrollArea(dynamic_cast<QWidget*>(this->parent()));
for(int i=0;i<_toDisplay.count();i++)
{ QLabel* newLabel = new QLabel(_toDisplay.at(i));
newLabel->setFixedWidth(280);
newLabel->setMinimumHeight(22);
newLabel->setStyleSheet("border: 1px solid black");
newLayout->addWidget(newLabel);
q++;
}
QPalette pal;
pal.setColor(QPalette::Background,QColor(230,200,167));
infoDialog->setFixedWidth(330);
infoDialog->setMinimumHeight(30+22*q);
infoDialog->setLayout(newLayout);
infoDialog->setAutoFillBackground(true);
infoDialog->setPalette(pal);
infoDialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::Dialog);
scrolArea->setWidget(infoDialog);
scrolArea->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::Dialog);
scrolArea->setMaximumHeight(infoDialog->size().height()+2);
scrolArea->setWindowTitle(QString("Info about"));
scrolArea->show();
}
示例8: tr
QWidget *MainWindow::InstallProcessBody(){
QString hits ="<p style='color:white; font-size:14px;'>" +
tr("Being installed. Please wait... ") +
"</p>";
QWidget *widget = new QWidget;
QVBoxLayout *layout = new QVBoxLayout;
layout->setSpacing(20);
layout->addSpacing(70);
DWaterProgress *iconHits = new DWaterProgress;
layout->addWidget(iconHits);
layout->setAlignment(iconHits, Qt::AlignCenter);
connect(this, SIGNAL(progressChanged(int)),
iconHits, SLOT(setProgress(int)));
connect (this,SIGNAL(progressDone()),
iconHits, SLOT(stop()));
iconHits->start();
QLabel *textHits = new QLabel;
textHits->setAlignment(Qt::AlignCenter);
textHits->setFixedWidth(260);
textHits->setWordWrap(true);
textHits->setText(hits);
layout->addWidget(textHits);
layout->setAlignment(textHits, Qt::AlignCenter);
widget->setLayout(layout);
return widget;
}
示例9: QLabel
QLabel * create_label(const QString & text)
{
QLabel * label = new QLabel(text);
label->setFixedWidth(50);
label->setAlignment(Qt::AlignCenter);
return label;
}
示例10: getQLabel
QLabel* MainWindow::getQLabel()
{
QLabel *lbl = new QLabel(this);
lbl->setAlignment(Qt::AlignRight | Qt::AlignTop);
lbl->setFixedWidth(LBL_WIDTH);
return lbl;
}
示例11: ChannelWidget
MainWidget::MainWidget(Widget* p_pMatrix) : ChannelWidget()
, m_pMatrix(p_pMatrix)
{
QVBoxLayout* layout = new QVBoxLayout;
setLayout(layout);
setFixedWidth(CHANNEL_WIDTH);
layout->setSpacing(0);
layout->setMargin(0);
{
QLabel *label = new QLabel(trUtf8("Phone"));
label->setFixedWidth(CHANNEL_WIDTH);
label->setAlignment(Qt::AlignHCenter);
layout->addWidget(label);
}
phone = m_pMatrix->createRotary(OUT, MAIN, FADER, PFL);
layout->addWidget(phone);
{
Widget::addSpacer(layout);
m_pLabel = new QLabel(trUtf8("Main"));
m_pLabel->setFixedWidth(CHANNEL_WIDTH);
m_pLabel->setAlignment(Qt::AlignHCenter);
layout->addWidget(m_pLabel);
QFont font = m_pLabel->font();
font.setBold(true);
m_pLabel->setFont(font);
}
mute = m_pMatrix->createToggle(OUT, MAIN, MUTE);
layout->addWidget(mute);
// Widget::addLine(layout);
{
PixmapWidget *pw = new PixmapWidget(NULL);
pw->setPixmap("separator.svg");
pw->setFixedSize(CHANNEL_WIDTH, SEPARATOR_HEIGHT);
layout->addWidget(pw);
}
mono = m_pMatrix->createRotary(OUT, MAIN, FADER, MONO);
layout->addWidget(mono);
// Widget::addLine(layout);
{
PixmapWidget *pw = new PixmapWidget(NULL);
pw->setPixmap("separator.svg");
pw->setFixedSize(CHANNEL_WIDTH, SEPARATOR_HEIGHT);
layout->addWidget(pw);
}
bal = m_pMatrix->createRotary(OUT, MAIN, PAN_BAL);
layout->addWidget(bal);
afl = m_pMatrix->createToggle(OUT, MAIN, TO_AFL);
layout->addWidget(afl);
fader = m_pMatrix->createFader(OUT, MAIN, FADER, MAIN);
layout->addWidget(fader);
}
示例12: __initializeLayoutVertical
QLayout* ColorDlg::__initializeLayoutVertical() {
QGridLayout* pL = new QGridLayout( this, 8, 2, 5, 2 );
pL->addWidget(new QLabel(tr( "Line"), this), 0, 0);
pL->addWidget(pCB_Line, 0, 1);
pL->addWidget(new QLabel(tr( "Back"), this), 1, 0);
pL->addWidget(pCB_BGColor, 1, 1);
pL->addWidget(new QLabel(tr( "BallLine"), this), 2, 0);
pL->addWidget(pCB_BallLine, 2, 1);
QLabel* pTL;
pTL = new QLabel(this);
pTL->setFixedHeight(20);
pL->addMultiCellWidget(pTL, 3, 3, 0, 1);
pL->addMultiCellWidget(pRB_UseColorList, 4, 4, 0, 1);
pL->addMultiCellWidget(pRB_UseSameColor, 5, 5, 0, 1);
pTL = new QLabel(this);
pTL->setFixedWidth(60);
pL->addWidget(pTL, 6, 0);
pL->addWidget(pCB_BallColor, 6, 1);
pL->addMultiCellWidget( pOK, 7, 7, 0, 1 );
return pL;
}
示例13: SwitchToProcessUI
void DWindowUI::SwitchToProcessUI() {
QLayoutItem *child;
while ((child = actionLayout_->takeAt(0)) != 0) {
if (child->widget()) {
child->widget()->setVisible(false);
}
}
while ((child = selectLayout_->takeAt(0)) != 0) {
if (child->widget()) {
child->widget()->setVisible(false);
}
}
QLabel *processHints = new QLabel(tr("<a style='color:#ffffff; font-size:12px'>Please </a>"
"<a style='color:#ebab4c; font-size:12px'>DO NOT</a>"
"<a style='color:#ffffff; font-size:12px'> remove the USB flash drive or shutdown while file is writing.<a>"));
processHints->setFixedWidth(labelMaxWidth);
processHints->setWordWrap(true);
selectLayout_->addStretch();
selectLayout_->addWidget(processHints);
selectLayout_->setAlignment(processHints, Qt::AlignVCenter);
usbLabel_->setText("<p style='color:white; font-size:10px;'>0% </p>");
QMovie *processMovie = new QMovie(":/ui/images/process-active.gif");
processLabel_->setMovie(processMovie);
processMovie->start();
processTimer_ = new QTimer(this);
processTimer_->setInterval(5000);
connect(processTimer_, SIGNAL(timeout()), this, SLOT(checkProcess()));
processTimer_->start();
isoLabel_->start();
}
示例14: SubSection
SubSection(const QString & title, const QString & description, QLabel * imageLabel) : QWidget()
{
QHBoxLayout * mainHLayout = new QHBoxLayout();
setLayout(mainHLayout);
mainHLayout->addWidget(imageLabel);
QVBoxLayout * mainVLayout = new QVBoxLayout();
mainHLayout->addLayout(mainVLayout);
QLabel * titleLabel = new QLabel(title);
titleLabel->setStyleSheet("QLabel { font-size: 14px; font: bold; color: #242D31; }");
titleLabel->setWordWrap(true);
mainVLayout->addWidget(titleLabel);
QHBoxLayout * descriptionHLayout = new QHBoxLayout();
mainVLayout->addLayout(descriptionHLayout);
descriptionHLayout->addSpacing(35);
QLabel * descriptionLabel = new QLabel(description);
descriptionLabel->setFixedWidth(700);
descriptionLabel->setStyleSheet("QLabel { font-size: 14px; color: black; }");
descriptionLabel->setWordWrap(true);
descriptionHLayout->addWidget(descriptionLabel);
mainHLayout->setAlignment(Qt::AlignLeft);
}
示例15: addLayout
/*! Add a pair [label,layout] to main part of dialog, label is created from
\b QString \b nameLabel.
\n Recall \b addWidgetLayout(QWdiget* widget, QWdiget* layout).
*/
void Dialog::addLayout(QString labelName, QLayout *layout)
{
QLabel *label = new QLabel(labelName);
m_labelList.push_back(label);
label->setFixedWidth(m_labelWidth);
label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
addWidgetLayout(label, layout);
}