本文整理汇总了C++中QLabel::geometry方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::geometry方法的具体用法?C++ QLabel::geometry怎么用?C++ QLabel::geometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::geometry方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: furTimeHit
void MainWindow::furTimeHit()
{
Obstacle& o = Obstacle::instance();
for (unsigned int i = 0 ; i < furBalls.size(); i++)
{
QLabel * ball = furBalls[i];
ball->move(ball->x() + 2 , ball->y());
/*if (enemyExists == false)
{
}
else if (enemyExists)
{*/
for (unsigned int j = 0; j < o.spawnedObstacles.size(); j++)
{
QLabel * badGuy = new QLabel;
badGuy = o.spawnedObstacles[i];
if (/*enemyExists &&*/ ball->geometry().intersects(badGuy->geometry()))
{
//delete ball;
delete badGuy;
o.spawnedObstacles.erase(o.spawnedObstacles.cbegin());
furBalls.erase(furBalls.cbegin());
//ball = new QLabel(this);
badGuy = new QLabel(this);
delete ball;
ball = new QLabel(this);
}
else if (/*enemyExists && */badGuy->x() < -75)
{
delete badGuy;
o.spawnedObstacles.erase(o.spawnedObstacles.cbegin());
badGuy = new QLabel(this);
}
else if (ball->x() > this->width())
{
delete ball;
furBalls.erase(furBalls.cbegin());
ball = new QLabel(this);
}
}
// }
/*else if (ball->geometry().intersects(dog->geometry()))
{
delete dog;
//dog->deleteLater();
dog = new QLabel(this);
}*/
}
}
示例2: chooseNumber
void NumberChoiceLive::chooseNumber(int number) {
//numbers[number]->setText(QString(QChar(prizes[number])));
QPixmap *prizeImage;
switch(prizes[number]) {
case 'B':
if (isVisible()) QSound::play("media/sounds/PrizeBronze.wav");
prizeImage = prizeBronze;
break;
case 'S':
if (isVisible()) QSound::play("media/sounds/PrizeSilver.wav");
prizeImage = prizeSilver;
break;
case 'G':
if (isVisible()) QSound::play("media/sounds/PrizeGold.wav");
prizeImage = prizeGold;
break;
}
QPixmap smallerPrize = prizeImage->scaled(numbers[number]->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
QLabel *medal = new QLabel(numbers[number]->parentWidget());
medal->setAttribute(Qt::WA_DeleteOnClose);
medal->setPixmap(smallerPrize);
medal->resize(smallerPrize.size()); // Using . rather than -> with smallerPrize because smallerPrize isn't a pointer
medal->move(numbers[number]->geometry().center() - medal->geometry().center());
medal->show();
connect(this, SIGNAL(resetAll(bool)), medal, SLOT(close()));
}
示例3: upClicked
void ProcessingPipeline::upClicked( int id )
{
if( !isVeryTopElement( id ) )
{
int actualID = findId( currentProcessingStepOrder, id );
int oneButtonUpID = actualID - 1;
std::swap( currentProcessingStepOrder[ actualID ], currentProcessingStepOrder[ oneButtonUpID ] );
actualID = getActualID( actualID );
oneButtonUpID = getActualID( oneButtonUpID );
// swap the down button positions
QPushButton * clickedButtonDown = processingPipelineConfigWidget->getDownButtonById( actualID );
QRect tempPosDown = clickedButtonDown->geometry();
QPushButton * toSwapWithButtonDown = processingPipelineConfigWidget->getDownButtonById( oneButtonUpID );
clickedButtonDown->setGeometry( toSwapWithButtonDown->geometry() );
toSwapWithButtonDown->setGeometry( tempPosDown );
// swap the up button position
QPushButton * clickedButtonUp = processingPipelineConfigWidget->getUpButtonByID( actualID );
QRect tempPosUp = clickedButtonUp->geometry();
QPushButton * toSwapWithButtonUp = processingPipelineConfigWidget->getUpButtonByID( oneButtonUpID );
clickedButtonUp->setGeometry( toSwapWithButtonUp->geometry() );
toSwapWithButtonUp->setGeometry( tempPosUp );
// swap labels
QLabel * clickedLabel = processingPipelineConfigWidget->getLabelByID( actualID );
QRect tempPosLabel = clickedLabel->geometry();
QLabel * toSwapWithLabel = processingPipelineConfigWidget->getLabelByID( oneButtonUpID );
clickedLabel->setGeometry( toSwapWithLabel->geometry() );
toSwapWithLabel->setGeometry( tempPosLabel );
// config button
QPushButton * clickedButtonConfig = processingPipelineConfigWidget->getConfigButtonByID( actualID );
QRect tempPosConfig = clickedButtonConfig->geometry();
QPushButton * toSwapWithButtonConfig = processingPipelineConfigWidget->getConfigButtonByID( oneButtonUpID );
clickedButtonConfig->setGeometry( toSwapWithButtonConfig->geometry() );
toSwapWithButtonConfig->setGeometry( tempPosConfig );
// checkbox
QCheckBox * clickedCheckBox = processingPipelineConfigWidget->getCheckBoxByID( actualID );
QRect tempPosCheckbox = clickedCheckBox->geometry();
QCheckBox * toSwapWithCheckbox = processingPipelineConfigWidget->getCheckBoxByID( oneButtonUpID );
clickedCheckBox->setGeometry( toSwapWithCheckbox->geometry() );
toSwapWithCheckbox->setGeometry( tempPosCheckbox );
}
}
示例4: imagePosition
/*! \internal */
QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType)
{
QLabel *label = qobject_cast<QLabel *>(widget());
if (!label)
return QRect();
const QPixmap *pixmap = label->pixmap();
if (!pixmap)
return QRect();
switch (coordType) {
case QAccessible2::RelativeToScreen:
return QRect(label->mapToGlobal(label->pos()), label->size());
case QAccessible2::RelativeToParent:
return label->geometry();
}
return QRect();
}
示例5: wrapping
void tst_QFormLayout::wrapping()
{
QWidget *w = new QWidget;
QFormLayout *fl = new QFormLayout(w);
fl->setRowWrapPolicy(QFormLayout::WrapLongRows);
QLineEdit *le = new QLineEdit;
QLabel *lbl = new QLabel("A long label");
le->setMinimumWidth(200);
fl->addRow(lbl, le);
w->setFixedWidth(240);
w->show();
QCOMPARE(le->geometry().y() > lbl->geometry().y(), true);
//TODO: additional tests covering different wrapping cases
delete w;
}
示例6: cloudAntimation
void FCenterWindow::cloudAntimation(animation_Direction direction)
{
QLabel* circle = new QLabel(stackWidget->currentWidget());
QLabel* line = new QLabel(this);
line->setObjectName(QString("AntimationLine"));
line->resize(0, 2);
line->show();
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
circle->setPixmap(QPixmap::grabWidget(stackWidget->widget(preindex), stackWidget->widget(preindex)->geometry()));
#else
circle->setPixmap(stackWidget->widget(preindex)->grab());
#endif
// circle->setScaledContents(true);
circle->show();
circle->resize(stackWidget->currentWidget()->size());
QPropertyAnimation *animation = new QPropertyAnimation(circle, "geometry");
animation->setDuration(500);
animation->setStartValue(circle->geometry());
// QPropertyAnimation* animation_line = new QPropertyAnimation(line, "size");
// animation_line->setDuration(500);
// animation_line->setEasingCurve(QEasingCurve::OutQuart);
switch (direction) {
case animationTop:
animation->setEndValue(QRect(circle->x(), circle->y() - 10, circle->width(), 0));
break;
case animationTopRight:
animation->setEndValue(QRect(circle->width(), 0, 0, 0));
break;
case animationRight:
line->move(0, stackWidget->y() - 2);
animation->setEndValue(QRect(circle->width() + 3, 0, 0, circle->height()));
// animation_line->setStartValue(QSize(0, 2));
// animation_line->setEndValue(QSize(stackWidget->width(), 2));
break;
case animationBottomRight:
animation->setEndValue(QRect(circle->width(), circle->height(), 0, 0));
break;
case animationBottom:
animation->setEndValue(QRect(0, circle->height() + 10, circle->width(), 0));
break;
case animationBottomLeft:
animation->setEndValue(QRect(0, circle->height(), 0, 0));
break;
case animationLeft:
animation->setEndValue(QRect(-3, 0, 0, circle->height()));
line->move(stackWidget->x(), stackWidget->y() - 2);
// animation_line->setStartValue(QSize(0, 2));
// animation_line->setEndValue(QSize(stackWidget->width(), 2));
break;
case animationTopLeft:
animation->setEndValue(QRect(0, 0, 0, 0));
break;
case animationCenter:
animation->setEndValue(QRect(circle->width()/2, circle->height()/2, 0, 0));
break;
default:
break;
}
animation->setEasingCurve(QEasingCurve::OutQuart);
QPropertyAnimation* animation_opacity = new QPropertyAnimation(circle, "windowOpacity");
animation_opacity->setDuration(500);
animation_opacity->setStartValue(1);
animation_opacity->setEndValue(0);
animation_opacity->setEasingCurve(QEasingCurve::OutQuart);
QParallelAnimationGroup *group = new QParallelAnimationGroup;
connect(group,SIGNAL(finished()), circle, SLOT(hide()));
connect(group,SIGNAL(finished()), circle, SLOT(deleteLater()));
connect(group,SIGNAL(finished()), line, SLOT(deleteLater()));
connect(group,SIGNAL(finished()), group, SLOT(deleteLater()));
connect(group,SIGNAL(finished()), animation, SLOT(deleteLater()));
connect(group,SIGNAL(finished()), animation_opacity, SLOT(deleteLater()));
// connect(group,SIGNAL(finished()), animation_line, SLOT(deleteLater()));
group->addAnimation(animation);
group->addAnimation(animation_opacity);
// group->addAnimation(animation_line);
group->start();
}
示例7: fileDlg
ISOSelectView::ISOSelectView(QWidget *parent) : QFrame(parent)
{
setObjectName("ISOSelectView");
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(0, 9, 0, 0);
QLabel *m_title = new QLabel(tr("Select an ISO image file"));
m_title->setFixedHeight(38);
m_title->setStyleSheet("font-size: 26px;");
QLabel *isoIcon = new QLabel(this);
isoIcon->setObjectName("ISOIcon");
isoIcon->setFixedSize(96, 96);
isoIcon->setPixmap(WidgetUtil::getDpiPixmap(":/theme/light/image/media-optical-96px.svg", this));
QLabel *growIcon = new QLabel(this);
growIcon->setObjectName("GrowIcon");
growIcon->setPixmap(WidgetUtil::getDpiPixmap(":/theme/light/image/glow.svg", this));
growIcon->setFixedSize(220, 220);
growIcon->hide();
DropFrame *isoPanel = new DropFrame;
isoPanel->setObjectName("IosPanel");
isoPanel->setFixedSize(412, 322);
QVBoxLayout *isoPanelLayout = new QVBoxLayout(isoPanel);
isoPanelLayout->setMargin(0);
m_fileLabel = new QLabel(tr("Drag an ISO image file and drop it here"));
m_fileLabel->setObjectName("IsoFileName");
// m_fileLabel->setFixedHeight(18);
m_hits = new QLabel(tr("OR"));
m_hits->setObjectName("IsoHits");
m_hits->setFixedHeight(18);
QLabel *spliter = new QLabel;
spliter->setObjectName("IsoSpliter");
spliter->setFixedSize(230, 1);
m_fileSelect = new QLabel();
m_fileSelect->setObjectName("IsoFileSelect");
// m_fileSelect->setFixedHeight(15);
m_fileSelect->setOpenExternalLinks(false);
QString selectText = tr("Select an ISO image file");
QString linkText = QString(s_linkTemplate).arg(selectText).arg(selectText);
m_fileSelect->setText(linkText);
isoPanelLayout->addSpacing(62);
isoPanelLayout->addWidget(isoIcon, 0, Qt::AlignCenter);
isoPanelLayout->addSpacing(5);
isoPanelLayout->addWidget(m_fileLabel, 0, Qt::AlignCenter);
isoPanelLayout->addSpacing(4);
isoPanelLayout->addWidget(m_hits, 0, Qt::AlignCenter);
isoPanelLayout->addSpacing(7);
isoPanelLayout->addWidget(spliter, 0, Qt::AlignCenter);
isoPanelLayout->addSpacing(12);
isoPanelLayout->addWidget(m_fileSelect, 0, Qt::AlignCenter);
isoPanelLayout->addStretch();
m_nextSetp = new SuggestButton();
m_nextSetp->setObjectName("NextStepButton");
m_nextSetp->setText(tr("Next"));
m_nextSetp->setDisabled(true);
mainLayout->addWidget(m_title, 0, Qt::AlignCenter);
mainLayout->addSpacing(24);
mainLayout->addWidget(isoPanel, 0, Qt::AlignCenter);
mainLayout->addStretch();
mainLayout->addWidget(m_nextSetp, 0, Qt::AlignCenter);
this->setStyleSheet(WidgetUtil::getQss(":/theme/light/ISOSelectView.theme"));
#ifdef Q_OS_WIN
m_fileLabel->hide();
spliter->hide();
m_hits->hide();
#endif
connect(isoPanel, &DropFrame::fileAboutAccept, this, [ = ]() {
growIcon->show();
auto center = isoIcon->geometry().center();
growIcon->move(center);
auto topleft = growIcon->mapFromGlobal(isoIcon->mapToGlobal(center));
auto offset = 220 - 96;
topleft.setX(topleft.x() - offset / 2);
topleft.setY(topleft.y() - offset / 2);
growIcon->move(topleft);
isoPanel->setProperty("active", true);
this->style()->unpolish(isoPanel);
this->style()->polish(isoPanel);
});
connect(isoPanel, &DropFrame::fileCancel, this, [ = ]() {
growIcon->hide();
isoPanel->setProperty("active", false);
this->style()->unpolish(isoPanel);
this->style()->polish(isoPanel);
});
connect(m_fileSelect, &QLabel::linkActivated, this, [ = ](const QString & /*link*/) {
QFileDialog fileDlg(this);
//.........这里部分代码省略.........