本文整理汇总了C++中QLabel::setMovie方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::setMovie方法的具体用法?C++ QLabel::setMovie怎么用?C++ QLabel::setMovie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::setMovie方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateTabs
void TabBarWidget::updateTabs(int index)
{
if (index < 0 && sender() && sender()->inherits(QStringLiteral("Otter::Window").toLatin1()))
{
for (int i = 0; i < count(); ++i)
{
if (sender() == qvariant_cast<QObject*>(tabData(i)))
{
index = i;
break;
}
}
}
const int limit = ((index >= 0) ? (index + 1) : count());
for (int i = ((index >= 0) ? index : 0); i < limit; ++i)
{
const bool isLoading = getTabProperty(i, QLatin1String("isLoading"), false).toBool();
QLabel *label = qobject_cast<QLabel*>(tabButton(i, QTabBar::LeftSide));
if (label)
{
if (isLoading)
{
if (!label->movie())
{
QMovie *movie = new QMovie(QLatin1String(":/icons/loading.gif"), QByteArray(), label);
movie->start();
label->setMovie(movie);
}
}
else
{
if (label->movie())
{
label->movie()->deleteLater();
label->setMovie(NULL);
}
label->setPixmap(getTabProperty(i, QLatin1String("icon"), QIcon(getTabProperty(i, QLatin1String("isPrivate"), false).toBool() ? ":/icons/tab-private.png" : ":/icons/tab.png")).value<QIcon>().pixmap(16, 16));
}
}
}
showPreview(tabAt(mapFromGlobal(QCursor::pos())));
}
示例2: playMovie
void tst_QMovie::playMovie()
{
QFETCH(QString, fileName);
QFETCH(int, frameCount);
QMovie movie(fileName);
QCOMPARE(movie.state(), QMovie::NotRunning);
movie.setSpeed(1000);
movie.start();
QCOMPARE(movie.state(), QMovie::Running);
movie.setPaused(true);
QCOMPARE(movie.state(), QMovie::Paused);
movie.start();
QCOMPARE(movie.state(), QMovie::Running);
movie.stop();
QCOMPARE(movie.state(), QMovie::NotRunning);
movie.jumpToFrame(0);
QCOMPARE(movie.state(), QMovie::NotRunning);
movie.start();
QCOMPARE(movie.state(), QMovie::Running);
connect(&movie, SIGNAL(finished()), this, SLOT(exitLoopSlot()));
QLabel label;
label.setMovie(&movie);
label.show();
QTestEventLoop::instance().enterLoop(20);
QVERIFY2(!QTestEventLoop::instance().timeout(),
"Timed out while waiting for finished() signal");
QCOMPARE(movie.state(), QMovie::NotRunning);
QCOMPARE(movie.frameCount(), frameCount);
}
示例3: checkLogin
void LoginWidget::checkLogin()
{
QString user = _editUsername->text();
QString pass = _editPassword->text();
QString ip = _editIp->text();
QMovie *movie = new QMovie("./gui/ring.gif");
QLabel *processLabel = new QLabel(this);
processLabel->setMovie(movie);
movie->start();
_userString = user.toUtf8().constData();
_passString = pass.toUtf8().constData();
_ipString = ip.toUtf8().constData();
if (_userString == "" || _passString == "" || _ipString == "")
{
QMessageBox *msgBox = new QMessageBox(this);
msgBox->setText("Please fill the fields");
msgBox->exec();
}
else
{
_editPassword->clear();
this->clearLayout(_mainLayout);
_mainLayout->addWidget(processLabel, 0, 0, Qt::AlignCenter);
g_PTUser.logUser(_userString, _passString, _ipString);
}
}
示例4: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMovie *mov = new QMovie(":/img/pics/start.gif");
QLabel *label = new QLabel("",0);
label->setGeometry(450,200,500,300);
label->setMovie(mov);
mov->start();
label->setWindowFlags(Qt::FramelessWindowHint);
label->show();
QTime t;
t.start();
while(t.elapsed() < 1500)
{
a.processEvents();
}
MainWindow w;
w.show();
w.move((QApplication::desktop()->width()-w.width())/2,(QApplication::desktop()->height()-w.height())/2);
label->close();
return a.exec();
}
示例5: infiniteLoop
void tst_QMovie::infiniteLoop()
{
QLabel label;
label.show();
QMovie *movie = new QMovie(QLatin1String(":animations/corrupt.gif"), QByteArray(), &label);
label.setMovie(movie);
movie->start();
QTestEventLoop::instance().enterLoop(1);
QTestEventLoop::instance().timeout();
}
示例6: 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());
}
示例7: createLoadingView
void CloudView::createLoadingView()
{
loading_view_ = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout;
loading_view_->setLayout(layout);
QMovie *gif = new QMovie(":/images/loading.gif");
QLabel *label = new QLabel;
label->setMovie(gif);
label->setAlignment(Qt::AlignCenter);
gif->start();
layout->addWidget(label);
}
示例8: QGraphicsProxyWidget
void ImageProxyItem::Private::onFinished(int /*id*/, QMovie * movie) {
QLabel * label = new QLabel;
label->setMovie(movie);
movie->setParent(label);
movie->start();
label->resize(movie->frameRect().size());
QGraphicsProxyWidget * item = new QGraphicsProxyWidget(this->owner);
item->setWidget(label);
// HACK workaround for https://bugreports.qt.io/browse/QTBUG-55070
item->setOpacity(0.99);
this->movie = movie;
this->item = item;
this->activity = Activity::Activated;
emit this->owner->activated(this->owner);
}
示例9: main
int main(int argc, char *argv[])
{
Application app(argc, argv);
QEventLoop loop;
auto s(std::async(std::launch::async, [&loop]{ Datum::Solve solve(Datum::solve()); if (loop.isRunning()) { loop.quit(); } return std::move(solve); }));
QLabel splash;
splash.setMovie(new QMovie(([](){
static const QString basePath(":/splash/busy/");
const QStringList files(QDir(basePath).entryList(QStringList() << "*.gif"));
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> d(0,files.size() - 1);
const QString& result(files.at(d(gen)));
return basePath + result;
})()));
splash.movie()->start();
splash.show();
splash.setWindowTitle("computing. . .");
if (s.wait_until(std::chrono::system_clock::now()) != std::future_status::ready) {
loop.exec();
}
splash.hide();
app.showBarley();
Datum::Solve solve(s.get());
Datum d;
while (!solve.empty()) {
Application::showDatum(d);
d = d.realize(solve.top());
solve.pop();
}
Application::showDatum(d, false);
app.quit();
return 0;
}
示例10: QWidget
DemoWidget::DemoWidget(QWidget* _parent)
: QWidget(_parent)
{
QLightBoxWidget* lightBox = new QLightBoxWidget(this);
QLabel* text = new QLabel("Some information in <b>html</b> format<br/>"
"<ul><li>one</li><li>two</li><li>three</li></ul>");
QLabel* image = new QLabel;
image->setPixmap(QPixmap(":/image.jpg"));
QPushButton* showLB = new QPushButton(tr("Show"));
QGridLayout* mainLayout = new QGridLayout;
mainLayout->addWidget(text, 0, 0, Qt::AlignTop);
mainLayout->addWidget(image, 0, 1);
mainLayout->addWidget(showLB, 1, 1);
this->setLayout(mainLayout);
QLabel* lbTitle = new QLabel(tr("QLightBoxWidget"));
lbTitle->setStyleSheet("font-size: 28px; font-weight: bold; color: white");
QLabel* lbProgress = new QLabel;
QMovie* progressMovie = new QMovie(":/loader.gif");
lbProgress->setMovie(progressMovie);
progressMovie->start();
QLabel* lbDescription = new QLabel(tr("Example how to use QLightBoxWidget\n"
"in your QtWidgets applications..."));
lbDescription->setStyleSheet("color: white");
QPushButton* lbClose = new QPushButton(tr("Close"));
QGridLayout* lbLayout = new QGridLayout;
lbLayout->setRowStretch(0, 1);
lbLayout->setColumnStretch(0, 1);
lbLayout->addWidget(lbTitle, 1, 1);
lbLayout->addWidget(lbProgress, 1, 2, Qt::AlignRight);
lbLayout->setColumnStretch(3, 1);
lbLayout->addWidget(lbDescription, 2, 1, 1, 2);
lbLayout->addWidget(lbClose, 3, 2);
lbLayout->setRowStretch(4, 1);
connect(showLB, SIGNAL(clicked()), lightBox, SLOT(show()));
connect(lbClose, SIGNAL(clicked()), lightBox, SLOT(hide()));
lightBox->setLayout(lbLayout);
}
示例11: Init
void BusyIndicator::Init(const QString& text) {
movie_ = new QMovie(":spinner.gif"),
label_ = new QLabel;
QLabel* icon = new QLabel;
icon->setMovie(movie_);
icon->setMinimumSize(16, 16);
label_->setWordWrap(true);
label_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(icon);
layout->addSpacing(6);
layout->addWidget(label_);
set_text(text);
}
示例12: createDemoWidget
QWidget* createDemoWidget( const QString& movieFile )
{
QLabel* label = new QLabel;
QPushButton* playBtn = new QPushButton("Play");
QPushButton* stopBtn = new QPushButton("Stop");
QWidget* demo = new QWidget;
demo->setGeometry( 1, 1, 450, 450 );
demo->setLayout( new QVBoxLayout );
demo->layout()->addWidget( label );
demo->layout()->addWidget( playBtn );
demo->layout()->addWidget( stopBtn );
QMovie* movie = new QMovie(movieFile);
label->setMovie( movie );
label->setFixedHeight( 400 );
QObject::connect( playBtn, SIGNAL(clicked()), movie, SLOT(start()) );
QObject::connect( stopBtn, SIGNAL(clicked()), movie, SLOT(stop()) );
return demo;
}
示例13: QWidget
WaterWaveBtn::WaterWaveBtn(const QString& pngFile, QWidget *parent)
: QWidget(parent)
{
m_Movie = new QMovie(":/Resource/waterWave.gif");
m_Movie->setCacheMode(QMovie::CacheAll);
QLabel* waterWaveLabel = new QLabel(this);
waterWaveLabel->setMovie(m_Movie);
waterWaveLabel->setAttribute(Qt::WA_TranslucentBackground,true);
m_Movie->start();
m_Movie->setPaused(true);
LabelBtn* labelBtn = new LabelBtn(pngFile,":/Resource/sound.wav",this);
int size = QPixmap(":/Resource/waterWave.gif").width();
int gap = (size - labelBtn->width())/2;
labelBtn->move(gap,gap);
this->setFixedSize(size,size);
this->setAttribute(Qt::WA_TranslucentBackground);
// this->setWindowFlags(Qt::FramelessWindowHint|Qt::Window|Qt::WindowSystemMenuHint|Qt::WindowMinimizeButtonHint|Qt::WindowMaximizeButtonHint);
connect(labelBtn, SIGNAL(clicked()), this, SLOT(showWaterWave()));
}
示例14: QDialog
MovieDisplay::MovieDisplay(QWidget *parent) :
QDialog(parent),
ui(new Ui::MovieDisplay)
{
ui->setupUi(this);
//This block of code displays Llama gif when a riddle is anwsered correctly
QMovie *movie = new QMovie("://images/pm8gm.gif");
QLabel *processLabel = new QLabel(this);
processLabel->setGeometry(QRect(0,-75,300,300));
processLabel->setMovie(movie);
movie->start();
//This block of code plays an audio file when a riddle is answered correctly.
//IMPORTANT::Audio path must be hard coded to location of file!
QMediaPlayer *player = new QMediaPlayer(this);
player->setVolume(50);
player->setMedia(QUrl("http://shredder.resnet.bju/sound/649341_SOUNDDOGS__an.mp3"));
player->setVolume(100);
player->play();
}
示例15: spawnObstacles
QLabel* Obstacle::spawnObstacles(QWidget *parent)
{
Obstacle& o = Obstacle::instance();
QLabel * enemyLabel = new QLabel(parent);
Object * enemyObject;
int enemySelect = rand() % 3;
if(enemySelect==0){
QMovie * dogMovie = new QMovie(":/dog.gif");
enemyObject = new MadDog();
enemyLabel->setMovie(dogMovie);
enemyLabel->setGeometry(parent->width(),460,128,192);
dogMovie->start();
}else if(enemySelect == 1){
enemyObject = new LawnMower;
QPixmap mower(":/lawnmower2.png");
enemyLabel->setPixmap(mower);
enemyLabel->setGeometry(parent->width(), 514, 128,128);
}else if(enemySelect==2){
enemyObject =new Hole;
QPixmap hole(":/hole.png");
enemyLabel->setPixmap(hole);
enemyLabel->setGeometry(parent->width(),615,128,768);
}
enemyLabel->setScaledContents(true);
enemyLabel->show();
objects.push_back(enemyObject);
spawnedObstacles.push_back(enemyLabel);
return enemyLabel;
}