本文整理汇总了C++中QLabel::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::setAttribute方法的具体用法?C++ QLabel::setAttribute怎么用?C++ QLabel::setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QFrame
//! [0]
DragWidget::DragWidget(QWidget *parent)
: QFrame(parent)
{
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
#else
setMinimumSize(200, 200);
#endif
setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
setAcceptDrops(true);
QLabel *boatIcon = new QLabel(this);
boatIcon->setPixmap(QPixmap(":/images/boat.png"));
boatIcon->move(10, 10);
boatIcon->show();
boatIcon->setAttribute(Qt::WA_DeleteOnClose);
QLabel *carIcon = new QLabel(this);
carIcon->setPixmap(QPixmap(":/images/car.png"));
carIcon->move(100, 10);
carIcon->show();
carIcon->setAttribute(Qt::WA_DeleteOnClose);
QLabel *houseIcon = new QLabel(this);
houseIcon->setPixmap(QPixmap(":/images/house.png"));
houseIcon->move(10, 80);
houseIcon->show();
houseIcon->setAttribute(Qt::WA_DeleteOnClose);
}
示例2: QFrame
//! [0]
DragWidget::DragWidget(QWidget *parent)
: QFrame(parent)
{
setMinimumSize(200, 200);
setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
setAcceptDrops(true);
QLabel *boatIcon = new QLabel(this);
boatIcon->setPixmap(QPixmap(":/images/boat.png"));
boatIcon->move(20, 20);
boatIcon->show();
boatIcon->setAttribute(Qt::WA_DeleteOnClose);
QLabel *carIcon = new QLabel(this);
carIcon->setPixmap(QPixmap(":/images/car.png"));
carIcon->move(120, 20);
carIcon->show();
carIcon->setAttribute(Qt::WA_DeleteOnClose);
QLabel *houseIcon = new QLabel(this);
houseIcon->setPixmap(QPixmap(":/images/house.png"));
houseIcon->move(20, 120);
houseIcon->show();
houseIcon->setAttribute(Qt::WA_DeleteOnClose);
}
示例3: Window
void Widget::Window(WeatherInfo *wi) {
QVBoxLayout *mainFrame = new QVBoxLayout;
QHBoxLayout *lineFrame = new QHBoxLayout;
this->setWindowIcon(QIcon(":/weather.png"));
QString text = QString("%1(%2)").arg(wi->GetCityName())
.arg(wi->GetCountry());
QLabel *Label = new QLabel;
Label->setAttribute(Qt::WA_DeleteOnClose);
Label->setText(text);
lineFrame->addWidget(Label);
int c = wi->GetWeatherCount();
int lastday = 0;
for(int i = 0; i != c; i++) {
uint dt = wi->GetKeyByIndex(i, { "dt" }).toUInt();
QDateTime dt_txt;
dt_txt.setTime_t(dt);
int day = dt_txt.date().day();
if(lastday != day) {
mainFrame->addLayout(lineFrame);
lineFrame = new QHBoxLayout;
}
QVBoxLayout *curFrame = new QVBoxLayout;
QLabel *imglabel = new QLabel;
imglabel->setAttribute(Qt::WA_DeleteOnClose);
QString key = wi->GetKeyByIndex(i, { "weather"}).toList()[0].
toMap()["icon"].toString();
imglabel->setPixmap(wi->GetImg(key));
curFrame->addWidget(imglabel);
QLabel *datetime = new QLabel;
datetime->setAttribute(Qt::WA_DeleteOnClose);
datetime->setText(dt_txt.toString(tr("ddd MM-dd:HH(t)")));
curFrame->addWidget(datetime);
QLabel *w = new QLabel;
w->setAttribute(Qt::WA_DeleteOnClose);
text = tr("%1 %4% %5")
.arg(wi->GetKeyByIndex(i, { "main", "temp" }).toFloat())
.arg(wi->GetKeyByIndex(i, { "main", "humidity" }).toFloat())
.arg(wi->GetKeyByIndex(i, { "weather" }).
toList()[0].toMap()["description"].toString());
w->setText(text);
curFrame->addWidget(w);
lineFrame->addLayout(curFrame);
lastday = day;
}
setLayout(mainFrame);
show();
}
示例4: buildGameUi
void MainWindow::buildGameUi()
{
// Create score board
QLabel *scoreBoard = new QLabel();
//scoreBoard->setAttribute(Qt::WA_TranslucentBackground);
scoreBoard->setAlignment(Qt::AlignCenter);
scoreBoard->setText("<font color='white'>SCORE</font>");
QFont *font = new QFont();
font->setPointSizeF(18);
font->setBold(true);
font->setFamily(QString("Adobe Devanagari"));
scoreBoard->setFont(*font);
scoreBoard->setGeometry(QRect(20,20,120,30));
scene->addWidget(scoreBoard);
otherSceneObjectList.push_back(scoreBoard);
// score points
scoreBoardPoints = new QLabel();
scoreBoard->setAttribute(Qt::WA_TranslucentBackground);
scoreBoardPoints->setNum(this->scorePoint);
scoreBoardPoints->setFont(*font);
scoreBoardPoints->setGeometry(QRect(200,20,90,30));
scene->addWidget(scoreBoardPoints);
otherSceneObjectList.push_back(scoreBoardPoints);
// add timer to update
connect(&timer, SIGNAL(timeout()), this,SLOT(updateScorePonit()));
// Create birdleft board
QLabel *birdLeftBoard = new QLabel();
birdLeftBoard->setAttribute(Qt::WA_TranslucentBackground);
birdLeftBoard->setAlignment(Qt::AlignCenter);
birdLeftBoard->setText("<font color='white'>BIRD LEFT</font>");
birdLeftBoard->setFont(*font);
birdLeftBoard->setGeometry(QRect(20,50,150,30));
scene->addWidget(birdLeftBoard);
otherSceneObjectList.push_back(birdLeftBoard);
// bird left num
birdLeftNumbers = new QLabel();
//scoreBoard->setAttribute(Qt::WA_TranslucentBackground);
birdLeftNumbers->setNum(this->scorePoint);
birdLeftNumbers->setFont(*font);
birdLeftNumbers->setGeometry(QRect(200,50,90,30));
scene->addWidget(birdLeftNumbers);
otherSceneObjectList.push_back(birdLeftNumbers);
// add timer to update
connect(&timer, SIGNAL(timeout()), this,SLOT(updateBirdLeft()));
}
示例5: QStatusBar
StatusBar::StatusBar( QWidget* parent )
: QStatusBar( parent )
{
// create labels
QLabel* label;
label = ( mLabels[ltCursorPosition] = new QLabel( this ) );
label->setToolTip( tr( "Cursor position" ) );
label = ( mLabels[ltSaveState] = new QLabel( this ) );
label->setToolTip( tr( "Modification state of file" ) );
label = ( mLabels[ltEOLMode] = new QLabel( this ) );
label->setToolTip( tr( "EOL mode" ) );
label = ( mLabels[ltIndentMode] = new QLabel( this ) );
label->setToolTip( tr( "Indentation mode" ) );
// add labels
for ( int i = ltCursorPosition; i < ltIndentMode +1; i++ )
{
label = mLabels[ i ];
addPermanentWidget( label );
label->setMargin( 2 );
label->setFrameStyle( QFrame::NoFrame );
label->setAttribute( Qt::WA_MacSmallSize );
}
// force remove statusbar label frame
setStyleSheet( "QStatusBar::item { border: 0px; }" );
// connections
connect( this, SIGNAL( messageChanged( const QString& ) ), this, SLOT( setMessage( const QString& ) ) );
}
示例6: dropEvent
void crobot::dropEvent(QDropEvent *event)
{
if (event->mimeData()->hasFormat("application/x-dnditemdata")) {
QByteArray itemData = event->mimeData()->data("application/x-dnditemdata");
QDataStream dataStream(&itemData, QIODevice::ReadOnly);
QPixmap pixmap;
QPoint offset;
dataStream >> pixmap >> offset;
QLabel *newIcon = new QLabel(this);
newIcon->setPixmap(pixmap);
newIcon->move(event->pos() - offset);
newIcon->show();
newIcon->setAttribute(Qt::WA_DeleteOnClose);
if (event->source() == this) {
event->setDropAction(Qt::MoveAction);
event->accept();
} else {
event->acceptProposedAction();
}
} else {
示例7: QVBoxLayout
void tst_QWidget_window::tst_recreateWindow_QTBUG40817()
{
QTabWidget tab;
QWidget *w = new QWidget;
tab.addTab(w, "Tab1");
QVBoxLayout *vl = new QVBoxLayout(w);
QLabel *lbl = new QLabel("HELLO1");
lbl->setObjectName("label1");
vl->addWidget(lbl);
w = new QWidget;
tab.addTab(w, "Tab2");
vl = new QVBoxLayout(w);
lbl = new QLabel("HELLO2");
lbl->setAttribute(Qt::WA_NativeWindow);
lbl->setObjectName("label2");
vl->addWidget(lbl);
tab.show();
QVERIFY(QTest::qWaitForWindowExposed(&tab));
QWindow *win = tab.windowHandle();
win->destroy();
QWindowPrivate *p = qt_window_private(win);
p->create(true);
win->show();
tab.setCurrentIndex(1);
}
示例8: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
int x=QApplication::desktop()->width(),y=QApplication::desktop()->height();
MainWindow w(x,y);
Off off(x,y);
off.setAttribute(Qt::WA_TranslucentBackground);
off.setWindowFlags(Qt::WindowStaysOnTopHint|Qt::FramelessWindowHint|Qt::Tool);//最前端和透明
w.setFixedSize(x,y);
w.setAttribute(Qt::WA_TranslucentBackground);
w.setWindowFlags(Qt::WindowStaysOnTopHint|Qt::FramelessWindowHint|Qt::Tool);//最前端和透明
QImage image(":/image/3.png");
QPixmap pixmap=QPixmap::fromImage(image.scaled(1477/2,1085/2));
QLabel label;
label.setFixedSize(1477/2,1085/2);
label.setPixmap(pixmap);
label.setAttribute(Qt::WA_TranslucentBackground);
label.setWindowFlags(Qt::FramelessWindowHint|Qt::Tool|Qt::WindowStaysOnBottomHint);
taskbar(label,x,y);
label.show();
off.show();
w.show();
QObject::connect(&off,SIGNAL(suspend_movie()),&w,SLOT(suspend()));
QObject::connect(&off,SIGNAL(quit()),&a,SLOT(quit()));
return a.exec();
}
示例9:
void
GraphicalRack::setText(const Quackle::LetterString &text)
{
// clear old labels
while(m_layout->count()) {
QLabel *label = qobject_cast<QLabel*>(m_layout->itemAt(0)->widget());
if (!label) {
break;
}
m_layout->removeWidget(label);
label->close();
}
PixmapCacher::self()->invalidate();
for (int i = text.size() - 1; i >= 0 ; --i) {
QLabel *label = new QLabel;
label->setAttribute (Qt::WA_DeleteOnClose);
TileWidget tile;
Quackle::Board::TileInformation info;
info.isOnRack = true;
info.letter = text[i];
info.tileType = Quackle::Board::LetterTile;
tile.setInformation(info);
tile.setSideLength(50);
tile.prepare();
label->setPixmap(tile.tilePixmap());
m_layout->insertWidget(0, label);
}
}
示例10: showAmbientOcclusionMaps
void MainWindow::showAmbientOcclusionMaps()
{
const GFX::Buffer<GFX::ColorF> &aoMap = ui->pdb->aoMap();
int size = aoMap.height();
int numAtoms = aoMap.width() / size;
int w = (1000 / size);
int h = numAtoms / w + 1;
QImage image(w * size, h * size, QImage::Format_RGB32);
for (int a = 0; a < numAtoms; ++a) {
int b = a / w;
for (int j = 0; j < size; ++j)
for (int i = (a % w) * size; i < ((a + 1) % w) * size; ++i) {
const GFX::Color &color = aoMap(i + a * size, j);
image.setPixel(i, j + b * size, color.toARGB());
}
}
QLabel *lbl = new QLabel;
lbl->setAttribute(Qt::WA_DeleteOnClose);
lbl->setPixmap(QPixmap::fromImage(image));
lbl->show();
}
示例11: 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()));
}
示例12: loadIcon
void DragWidget::loadIcon(const char filename[],
int x, int y) {
QLabel* boatIcon = new QLabel(this);
boatIcon->setPixmap(QPixmap(filename));
boatIcon->move(x, y);
boatIcon->show();
boatIcon->setAttribute(Qt::WA_DeleteOnClose);
}
示例13: QGraphicsProxyWidget
QGraphicsProxyWidget *
UpcomingEventsWidget::createLabel( const QString &text, QSizePolicy::Policy hPolicy )
{
QLabel *label = new QLabel;
label->setAttribute( Qt::WA_NoSystemBackground );
label->setMinimumWidth( 10 );
label->setSizePolicy( hPolicy, QSizePolicy::Preferred );
label->setText( text );
label->setWordWrap( false );
QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget( this );
proxy->setWidget( label );
return proxy;
}
示例14: pix
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setAcceptDrops(true);
QLabel *label = new QLabel(this);
QPixmap pix(":/image/images/C_171.png");
label->setPixmap(pix);
label->resize(pix.size());
label->move(100,100);
label->setAttribute(Qt::WA_DeleteOnClose);
}
示例15: QFrame
DragWidgetBin::DragWidgetBin(QWidget *parent)
: QFrame(parent)
{
setMinimumSize(100, 100);
setMaximumSize(100, 100);
setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
setAcceptDrops(true);
QLabel *binIcon = new QLabel(this);
binIcon->setPixmap(QPixmap(":/images/bin.png"));
binIcon->move(15, 15);
binIcon->show();
binIcon->setAttribute(Qt::WA_DeleteOnClose);
}