本文整理汇总了C++中QLabel::sizeHint方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::sizeHint方法的具体用法?C++ QLabel::sizeHint怎么用?C++ QLabel::sizeHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::sizeHint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layout
void ProgView::layout() {
int maxHeight = 0;
for (int i = 0; i < channelBar.size(); i++) {
int y = 0;
QLabel *chan = channelBar.at(i);
int x = getX(i);
int width = getKey(CHANNEL_WIDTH).toInt();
int height = chan->heightForWidth(width);
if (height > maxHeight) {
maxHeight = height;
}
chan->setGeometry(x, y, width, height);
chan->show();
//qDebug() << "x: " << x << "y: " << y;
//qDebug() << chan->text();
}
CHANNELBAR_HEIGHT.def = maxHeight;
setKey(CHANNELBAR_HEIGHT);
for (int i = 0; i < timeLine.size(); i++) {
int x = 0;
QLabel *lab = timeLine.at(i);
int y = getY(timeLineDate.value(lab));
lab->setGeometry(x, y, lab->sizeHint().width(),
lab->sizeHint().height());
lab->show();
//qDebug() << "x: " << x << "y: " << y;
//qDebug() << lab->text();
}
}
示例2: QTableView
IrsView::IrsView(QAbstractTableModel* model, QWidget* parent) : QTableView(parent)
{
this->setModel(model);
this->setAlternatingRowColors(true);
this->setSelectionMode(QAbstractItemView::SingleSelection);
this->setSelectionBehavior(QAbstractItemView::SelectRows);
LineEditDelegate* delegate = new LineEditDelegate();
this->setItemDelegate(delegate);
this->setContextMenuPolicy(Qt::DefaultContextMenu);
QLabel* tmp = new QLabel("W88 sec, 192000Hz/32bit, 99999-99999 Hz");
int columnWidth = tmp->sizeHint().width();
delete tmp;
this->setColumnWidth(0, columnWidth);
this->setColumnWidth(1, columnWidth);
tmp = new QLabel("WW Max Level, db");
columnWidth = tmp->sizeHint().width();
delete tmp;
this->setColumnWidth(2, columnWidth);
this->menu = new QMenu();
QAction* delAction = this->menu->addAction("Delete measurement");
connect(delAction, SIGNAL(triggered()), this, SLOT(deleteMeasure()));
// QHeaderView::sectionSizeFromContents()
}
示例3: setupGui
void ProgressDialog::setupGui(const QString& heading)
{
QVBox* vbox = makeVBoxMainWidget();
vbox->setSpacing(10);
QWidget* headingBox = new QWidget(vbox);
QHBoxLayout* hboxLayout = new QHBoxLayout(headingBox);
QLabel* textLabel = new QLabel(heading, headingBox);
textLabel->setMinimumWidth(textLabel->sizeHint().width());
textLabel->setFixedHeight(textLabel->sizeHint().height());
hboxLayout->addWidget(textLabel);
hboxLayout->addStretch();
d->gear = new KAnimWidget(QString("kde"), 32, headingBox);
d->gear->setFixedSize(32, 32);
hboxLayout->addWidget(d->gear);
d->resultbox = new QListBox(vbox);
d->resultbox->setSelectionMode(QListBox::NoSelection);
QFontMetrics fm(d->resultbox->fontMetrics());
d->resultbox->setMinimumSize(fm.width("0")*70, fm.lineSpacing()*8);
resize(sizeHint());
}
示例4: updateLayout
void TKAction::updateLayout(QWidget* base)
{
QLabel* textLabel = (QLabel*)base->child("text");
QLabel* pixLabel = (QLabel*)base->child("pixmap");
QWidget* w = (QWidget*)base->child("widget");
if (!textLabel || !pixLabel || !w)
return;
if (!text().isEmpty() && m_imode != TK::IconOnly ) {
textLabel->setText(text());
textLabel->show();
} else
textLabel->hide();
QPixmap pix;
if (hasIcon())
pix = iconSet(KIcon::Small).pixmap();
if (!icon().isEmpty())
pix = BarIcon(icon());
if (!pix.isNull() && m_imode != TK::TextOnly) {
pixLabel->setPixmap(pix);
pixLabel->show();
} else
pixLabel->hide();
base->setFixedWidth( w->sizeHint().width() +
(textLabel->isVisible() ? textLabel->sizeHint().width():0) +
(pixLabel->isVisible() ? pixLabel->sizeHint().width():0) );
}
示例5: AboutInherited
//-----------------------------------------------------------------------------
About::About (QWidget * aParent, const char *aName, bool aInit)
: AboutInherited(aParent, aName)
{
QBoxLayout* box;
QLabel* lbl;
QFrame* frm;
QString str;
QFont fnt;
if (aInit) return;
box = new QVBoxLayout(this, 20, 6);
lblTheme = new QLabel(" ", this);
fnt = lblTheme->font();
fnt.setPointSize(fnt.pointSize() * 1.2);
lblTheme->setFont(fnt);
lblTheme->setMinimumSize(lblTheme->sizeHint());
lblTheme->setAutoResize(true);
box->addWidget(lblTheme);
lblVersion = new QLabel(" ", this);
lblVersion->setMinimumSize(lblVersion->sizeHint());
lblVersion->setAutoResize(true);
box->addWidget(lblVersion);
lblAuthor = new QLabel(" ", this);
lblAuthor->setMinimumSize(lblAuthor->sizeHint());
lblAuthor->setAutoResize(true);
box->addWidget(lblAuthor);
lblHomepage = new QLabel(" ", this);
lblHomepage->setMinimumSize(lblHomepage->sizeHint());
lblHomepage->setAutoResize(true);
box->addWidget(lblHomepage);
frm = new QFrame(this);
frm->setFrameStyle(QFrame::HLine|QFrame::Raised);
box->addSpacing(5);
box->addWidget(frm);
box->addSpacing(5);
lbl = new QLabel(i18n("KDE Theme Manager"), this);
lbl->setFont(fnt);
lbl->setMinimumSize(lbl->sizeHint());
box->addWidget(lbl);
str.sprintf(i18n("Version %s\n\n"
"Copyright (C) 1998 by\n%s\n\n"
"Gnu Public License (GPL)"),
KTHEME_VERSION,
"Stefan Taferner <[email protected]>\n"
"Waldo Bastian <[email protected]>");
lbl = new QLabel(str, this);
lbl->setMinimumSize(lbl->sizeHint());
box->addWidget(lbl);
box->addStretch(1000);
box->activate();
}
示例6: fillPartialArchiveItem
void ArchiveList::fillPartialArchiveItem(PartialArchive *a, QTreeWidgetItem *item)
{
QTreeWidgetItem *subItem = new QTreeWidgetItem(item);
QPushButton *pauseButton = new QPushButton();
pauseButton->setText(a->isDownloading() ? tr("Pause") : tr("Continue"));
connect(pauseButton, SIGNAL(clicked()), a, SLOT(togglePauseDownload()));
downloadPausedMapper->setMapping(a, pauseButton);
downloadStartedMapper->setMapping(a, pauseButton);
connect(a, SIGNAL(downloadStarted()), downloadStartedMapper, SLOT(map()));
connect(a, SIGNAL(downloadPaused()), downloadPausedMapper, SLOT(map()));
int pbarColumn;
if (compactLayout) {
pbarColumn = 1;
subItem->setSizeHint(1, pauseButton->sizeHint());
setItemWidget(subItem, 1, pauseButton);
QPushButton *detailsButton = new QPushButton(tr("Details"));
showDetailsMapper->setMapping(detailsButton, a);
connect(detailsButton, SIGNAL(clicked()), showDetailsMapper, SLOT(map()));
subItem->setSizeHint(0, detailsButton->sizeHint());
setItemWidget(subItem, 0, detailsButton);
} else {
pbarColumn = 2;
item->setSizeHint(3, pauseButton->sizeHint());
setItemWidget(item, 3, pauseButton);
item->setText(1, a->getSizeMB());
QLabel *peerInfo = new QLabel();
subItem->setSizeHint(1, peerInfo->sizeHint());
setItemWidget(subItem, 1, peerInfo);
connect(a, SIGNAL(peerInfoUpdated(QString)), peerInfo, SLOT(setText(QString)));
QLabel *speedText = new QLabel();
subItem->setSizeHint(2, speedText->sizeHint());
setItemWidget(subItem, 2, speedText);
connect(a, SIGNAL(speedTextUpdated(QString)), speedText, SLOT(setText(QString)));
QLabel *statusText = new QLabel();
subItem->setSizeHint(3, statusText->sizeHint());
setItemWidget(subItem, 3, statusText);
connect(a, SIGNAL(statusTextUpdated(QString)), statusText, SLOT(setText(QString)));
}
QProgressBar *pbar = new QProgressBar();
pbar->setMinimum(0);
pbar->setMaximum(100);
item->setSizeHint(pbarColumn, pbar->sizeHint());
setItemWidget(item, pbarColumn, pbar);
connect(a, SIGNAL(progressUpdated(int)), pbar, SLOT(setValue(int)));
a->emitStatusEvents();
}
示例7: QDialog
SaveScm::SaveScm( QWidget *parent, const char *name )
: QDialog( parent, name, TRUE )
{
setFocusPolicy(QWidget::StrongFocus);
setCaption( i18n("Add a color scheme"));
QBoxLayout *topLayout = new QVBoxLayout( this, 10 );
QBoxLayout *stackLayout = new QVBoxLayout( 3 );
topLayout->addLayout( stackLayout );
nameLine = new QLineEdit( this );
nameLine->setFocus();
nameLine->setMaxLength(18);
nameLine->setFixedHeight( nameLine->sizeHint().height() );
QLabel* tmpQLabel;
tmpQLabel = new QLabel( nameLine,
i18n( "&Enter a name for the new color scheme\n"\
"to be added to your personal list.\n\n"\
"The colors currently used in the preview will\n"\
"be copied into this scheme to begin with." ), this );
tmpQLabel->setAlignment( AlignLeft | AlignBottom | ShowPrefix );
tmpQLabel->setFixedHeight( tmpQLabel->sizeHint().height() );
tmpQLabel->setMinimumWidth( tmpQLabel->sizeHint().width() );
stackLayout->addStretch( 10 );
stackLayout->addWidget( tmpQLabel );
stackLayout->addWidget( nameLine );
QFrame* tmpQFrame;
tmpQFrame = new QFrame( this );
tmpQFrame->setFrameStyle( QFrame::HLine | QFrame::Sunken );
tmpQFrame->setMinimumHeight( tmpQFrame->sizeHint().height() );
topLayout->addWidget( tmpQFrame );
KButtonBox *bbox = new KButtonBox( this );
bbox->addStretch( 10 );
QPushButton *ok = bbox->addButton( i18n( "&OK" ) );
connect( ok, SIGNAL( clicked() ), SLOT( accept() ) );
QPushButton *cancel = bbox->addButton( i18n( "&Cancel" ) );
connect( cancel, SIGNAL( clicked() ), SLOT( reject() ) );
bbox->layout();
topLayout->addWidget( bbox );
topLayout->activate();
resize( 250, 0 );
}
示例8: KConfigWidget
KLocaleConfig::KLocaleConfig(QWidget *parent, const char *name)
: KConfigWidget (parent, name)
{
QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
QGridLayout *tl1 = new QGridLayout(5, 4, 5);
tl->addLayout(tl1);
tl->addStretch(1);
gbox = new QGroupBox(klocale->translate("Language"), this);
tl1->addMultiCellWidget(gbox, 0, 4, 0, 3);
tl1->addRowSpacing(0, 10);
tl1->addRowSpacing(4, 15);
tl1->addColSpacing(0, 10);
tl1->addColSpacing(3, 10);
tl1->setColStretch(2, 1);
changedFlag = FALSE;
QLabel *label = new QLabel(klocale->translate("First"), gbox);
label->setMinimumSize(label->sizeHint());
combo1 = new KLanguageCombo(gbox);
combo1->setMinimumWidth(combo1->sizeHint().width());
combo1->setFixedHeight(combo1->sizeHint().height());
label->setBuddy(combo1);
connect(combo1,SIGNAL(highlighted(int)),this,SLOT(changed(int)));
tl1->addWidget(label, 1, 1);
tl1->addWidget(combo1, 1, 2);
label = new QLabel(klocale->translate("Second"), gbox);
label->setMinimumSize(label->sizeHint());
combo2 = new KLanguageCombo(gbox);
combo2->setMinimumWidth(combo2->sizeHint().width());
combo2->setFixedHeight(combo2->sizeHint().height());
label->setBuddy(combo2);
connect(combo2,SIGNAL(highlighted(int)),this,SLOT(changed(int)));
tl1->addWidget(label, 2, 1);
tl1->addWidget(combo2, 2, 2);
label = new QLabel(klocale->translate("Third"), gbox);
label->setMinimumSize(label->sizeHint());
combo3 = new KLanguageCombo(gbox);
combo3->setMinimumWidth(combo3->sizeHint().width());
combo3->setFixedHeight(combo3->sizeHint().height());
label->setBuddy(combo3);
connect(combo3,SIGNAL(highlighted(int)),this,SLOT(changed(int)));
tl1->addWidget(label, 3, 1);
tl1->addWidget(combo3, 3, 2);
tl->activate();
loadSettings();
}
示例9: 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()));
}
示例10: setMovie
void ImageView::setMovie(QMovie *movie)
{
reset();
QLabel *label = new QLabel();
label->setMovie(movie);
movie->setParent(label);
movie->start();
m_proxy = m_scene->addWidget(label);
m_scene->setSceneRect(0, 0, label->sizeHint().width(), label->sizeHint().height());
}
示例11: QDialog
/**
* Constructor
*/
ClsQPrcMonitor::ClsQPrcMonitor(QWidget *parent, const char * /* name=0 */, WFlags /* f=0 */) :
// QWidget ( parent, name, WStyle_Title |WStyle_NoBorder ) {
QDialog ( parent) {
QPixmap qpixmapPrc_alive = QPixmap (prc_alive);
qpixmapPrc_launched = QPixmap (prc_launched);
qpixmapPrc_ready = QPixmap (prc_ready);
qpixmapPrc_sfp = QPixmap (prc_sfp);
qpixmapPrc_mt = QPixmap (prc_mt);
this->setBackgroundColor(QColor(0,0,0));
qgltPrcs = new QGridLayout( this, 1, 8, 1 );
QLabel *l;
l = new QLabel(" PrcID ", this, "PrcID", 0);
l->setFixedHeight(l->sizeHint().height());
qgltPrcs->addWidget(l,0,0);
l = new QLabel("port ", this, "port", 0);
l->setFixedHeight(l->sizeHint().height());
qgltPrcs->addWidget(l,0,1);
l = new QLabel("A", this, "A", 0); l->setAlignment(AlignCenter);
QToolTip::add( l, "Prc alive" );
qgltPrcs->addWidget(l,0,2);
l = new QLabel("P", this, "P", 0); l->setAlignment(AlignCenter);
QToolTip::add( l, "Prc systemfile parsed" );
qgltPrcs->addWidget(l,0,3);
l = new QLabel("B", this, "B", 0); l->setAlignment(AlignCenter);
QToolTip::add( l, "Prc system buildt" );
qgltPrcs->addWidget(l,0,4);
l = new QLabel("C", this, "C", 0); l->setAlignment(AlignCenter);
QToolTip::add( l, "Prc connected" );
qgltPrcs->addWidget(l,0,5);
l = new QLabel("R", this, "R", 0); l->setAlignment(AlignCenter);
QToolTip::add( l, "Prc ready" );
qgltPrcs->addWidget(l,0,6);
l = new QLabel(" speed ", this, "speed", 0);
l->setFixedHeight(l->sizeHint().height());
qgltPrcs->addWidget(l,0,NR_STATES+2);
};
示例12: QDialog
KResize::KResize(QWidget *parent, const char *name, bool m, const QSize s )
: QDialog( parent, name, m )
{
setFocusPolicy(QWidget::NoFocus);
grp = new QGroupBox(i18n("Size:"), this);
QLabel *label = new QLabel("X", grp);
x_line = new KIntegerLine(grp);
connect(x_line, SIGNAL(valueChanged(int)), SLOT(checkValue(int)));
x_line->setFixedSize(100, label->sizeHint().height()+10);
y_line = new KIntegerLine(grp);
connect(y_line, SIGNAL(valueChanged(int)), SLOT(checkValue(int)));
y_line->setFixedSize(100, label->sizeHint().height()+10);
label->setFixedSize(label->sizeHint());
ml = new QVBoxLayout(this, 10);
ml->addWidget(grp, 10, AlignLeft);
l0 = new QHBoxLayout(grp, 20);
l0->addWidget(x_line);
l0->addWidget(label);
l0->addWidget(y_line);
l0->activate();
if(testWFlags(WType_Modal))
{
connect(x_line, SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
connect(y_line, SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
ok = new QPushButton(i18n("&OK"), this);
connect(ok, SIGNAL(clicked()), SLOT(accept()));
ok->setFixedSize(ok->sizeHint());
ok->setEnabled(false);
ok->setDefault(true);
cancel = new QPushButton(i18n("&Cancel"), this);
connect(cancel, SIGNAL(clicked()), SLOT(reject()));
cancel->setFixedSize(cancel->sizeHint());
QBoxLayout *l1 = new QHBoxLayout();
ml->addLayout(l1);
l1->addWidget(ok);
l1->addWidget(cancel);
l1->addStretch(1);
ml->freeze();
setCaption(i18n("Select size:"));
}
else
ml->activate();
x_line->setValue(s.width());
y_line->setValue(s.height());
checkValue(0);
}
示例13: slotIdentifyScreens
void BGDialog::slotIdentifyScreens()
{
// Taken from PositionTab::showIdentify in kdebase/kcontrol/kicker/positiontab_impl.cpp
for (unsigned s = 0; s < m_numScreens; s++) {
QLabel *screenLabel = new QLabel(0, Qt::X11BypassWindowManagerHint);
screenLabel->setObjectName("Screen Identify");
QFont identifyFont(KGlobalSettings::generalFont());
identifyFont.setPixelSize(100);
screenLabel->setFont(identifyFont);
screenLabel->setFrameStyle(QFrame::Panel);
screenLabel->setFrameShadow(QFrame::Plain);
screenLabel->setAlignment(Qt::AlignCenter);
screenLabel->setNum(int(s + 1));
// BUGLET: we should not allow the identification to be entered again
// until the timer fires.
QTimer::singleShot(1500, screenLabel, SLOT(deleteLater()));
QPoint screenCenter(QApplication::desktop()->screenGeometry(s).center());
QRect targetGeometry(QPoint(0, 0), screenLabel->sizeHint());
targetGeometry.moveCenter(screenCenter);
screenLabel->setGeometry(targetGeometry);
screenLabel->show();
}
}
示例14: QHBox
void Wizard::setupPage1()
{
page1 = new QHBox( this );
page1->setSpacing(8);
QLabel *info = new QLabel( page1 );
info->setPalette( yellow );
info->setText( "Enter your personal\n"
"key here.\n\n"
"Your personal key\n"
"consists of 4 digits" );
info->setIndent( 8 );
info->setMaximumWidth( info->sizeHint().width() );
QVBox *page = new QVBox( page1 );
QHBox *row1 = new QHBox( page );
(void)new QLabel( "Key:", row1 );
key = new QLineEdit( row1 );
key->setMaxLength( 4 );
key->setValidator( new QIntValidator( 9999, 0, key ) );
connect( key, SIGNAL( textChanged( const QString & ) ), this, SLOT( keyChanged( const QString & ) ) );
addPage( page1, "Personal Key" );
setNextEnabled( page1, FALSE );
setHelpEnabled( page1, FALSE );
}
示例15: QHBox
QWidget *Summary::createHeader(QWidget *parent, const QPixmap &icon, const QString &heading)
{
QHBox *hbox = new QHBox(parent);
hbox->setMargin(2);
QFont boldFont;
boldFont.setBold(true);
boldFont.setPointSize(boldFont.pointSize() + 2);
QLabel *label = new QLabel(hbox);
label->setPixmap(icon);
label->setFixedSize(label->sizeHint());
label->setPaletteBackgroundColor(colorGroup().mid());
label->setAcceptDrops(true);
label = new QLabel(heading, hbox);
label->setAlignment(AlignLeft | AlignVCenter);
label->setIndent(KDialog::spacingHint());
label->setFont(boldFont);
label->setPaletteForegroundColor(colorGroup().light());
label->setPaletteBackgroundColor(colorGroup().mid());
hbox->setPaletteBackgroundColor(colorGroup().mid());
hbox->setMaximumHeight(hbox->minimumSizeHint().height());
return hbox;
}