当前位置: 首页>>代码示例>>C++>>正文


C++ QLabel::setAttribute方法代码示例

本文整理汇总了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);
}
开发者ID:stephaneAG,项目名称:PengPod700,代码行数:29,代码来源:dragwidget.cpp

示例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);
}
开发者ID:Fale,项目名称:qtmoko,代码行数:26,代码来源:dragwidget.cpp

示例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();
}
开发者ID:YeLee,项目名称:weather,代码行数:53,代码来源:winman.cpp

示例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()));
}
开发者ID:cccccroge,项目名称:pd2-Angrybird,代码行数:48,代码来源:mainwindow.cpp

示例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& ) ) );
}
开发者ID:pasnox,项目名称:monkeystudio2,代码行数:34,代码来源:StatusBar.cpp

示例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 {
开发者ID:mbozugrace,项目名称:HappyHours,代码行数:25,代码来源:crobot.cpp

示例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);
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:30,代码来源:tst_qwidget_window.cpp

示例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();
}
开发者ID:QtDevelopGroup,项目名称:desktopSnow,代码行数:26,代码来源:main.cpp

示例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);
	}
}
开发者ID:esaye,项目名称:quackle,代码行数:32,代码来源:rackdisplay.cpp

示例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();
}
开发者ID:timvdm,项目名称:ComputerGraphics,代码行数:28,代码来源:mainwindow.cpp

示例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()));
}
开发者ID:davidpuzey,项目名称:peanuts,代码行数:27,代码来源:NumberChoiceModule.cpp

示例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);
}
开发者ID:Chuvi-w,项目名称:cpp,代码行数:8,代码来源:dragwidget.cpp

示例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;
}
开发者ID:ErrAza,项目名称:amarok,代码行数:13,代码来源:UpcomingEventsWidget.cpp

示例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);
}
开发者ID:enbool,项目名称:test4,代码行数:13,代码来源:mainwindow.cpp

示例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);
}
开发者ID:rideofyourlife,项目名称:TrainSim,代码行数:14,代码来源:dragwidgetbin.cpp


注:本文中的QLabel::setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。