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


C++ QDeclarativeItem::setWidth方法代码示例

本文整理汇总了C++中QDeclarativeItem::setWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeItem::setWidth方法的具体用法?C++ QDeclarativeItem::setWidth怎么用?C++ QDeclarativeItem::setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDeclarativeItem的用法示例。


在下文中一共展示了QDeclarativeItem::setWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setCinamaList

void KinoafishaWidget::setCinamaList(const QList<Cinema *> cinemaList)
{
    QTime progressTime;
    qDebug() << "Set cinema list to qmlView...";
    progressTime.start();
    QSettings settings;
    QString affishaQmlPatch = settings.value(SETT_KEY_KINOAFISHA_QML_PATCH,
                                             QCoreApplication::applicationDirPath() +
                                             DEFATUL_SETT_VALUE_KINOAFISHA_QML_PATCH).toString();
    qDebug() << "Load qml " << affishaQmlPatch + "/Affisha.qml...";
    QTime loadTime;
    loadTime.start();
    if (!QFile::exists(affishaQmlPatch + "/Affisha.qml"))
    {
        qWarning() << "Affisha.qml not found";
        return;
    }
    setSource(QUrl::fromLocalFile(affishaQmlPatch + "/Affisha.qml"));
    qDebug() << "Load qml finished in " << loadTime.elapsed();
    QDeclarativeItem * rootItem = qobject_cast<QDeclarativeItem *>(rootObject());
    qDebug() << "Kinoafisha widget width " << _screenWidth <<" height " << _screenHeight;
    rootItem->setWidth(_screenWidth);
    rootItem->setHeight(_screenHeight);
    connect(rootObject(), SIGNAL(trailerPlayFinished(int)), this, SIGNAL(traylerPlayedFinised(int)));
    foreach (Cinema *currentCinema, cinemaList)
    {
        addCinema(currentCinema);
    }
开发者ID:0x6368656174,项目名称:iqMultipleDesktopVideo,代码行数:28,代码来源:kinoafishawidget.cpp

示例2: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

//![QDeclarativeView]
// Using QDeclarativeView
QDeclarativeView view;
view.setSource(QUrl::fromLocalFile("MyItem.qml"));
view.show();
QObject *object = view.rootObject();
//![QDeclarativeView]

//![properties]
object->setProperty("width", 500);
QDeclarativeProperty(object, "width").write(500);
//![properties]

//![cast]
QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(object);
item->setWidth(500);
//![cast]

//![findChild]
QObject *rect = object->findChild<QObject*>("rect");
if (rect)
    rect->setProperty("color", "red");
//![findChild]

//![QDeclarativeComponent-b]
delete object;
//![QDeclarativeComponent-b]

withComponent();

    return app.exec();
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:36,代码来源:main.cpp

示例3: updateTimeline


//.........这里部分代码省略.........
    m_totalWidth = totalRange * spacing;

    // Find region samples
    int minsample = 0;
    int maxsample = 0;

    for (int i = 0; i < length; ++i) {
        if (m_ends.at(i) >= m_startTime)
            break;
        minsample = i;
    }

    for (int i = minsample + 1; i < length; ++i) {
        maxsample = i;
        if (m_starts.at(i) > m_endTime)
            break;
    }

    //### overkill (if we can expose whether or not data is nested)
    for (int i = maxsample + 1; i < length; ++i) {
        if (m_starts.at(i) < m_endTime)
            maxsample = i;
    }

    //qDebug() << maxsample - minsample;

    if (updateStartX) {
        qreal oldStartX = m_startX;
        m_startX = qRound(m_startTime * spacing);
        if (m_startX != oldStartX) {
            emit startXChanged(m_startX);
        }
    }

    //### emitting this before startXChanged was causing issues
    if (m_totalWidth != oldtw)
        emit totalWidthChanged(m_totalWidth);

    //clear items no longer in view
    while (prevMin < minsample) {
        delete m_items.take(prevMin);
        ++prevMin;
    }
    while (prevMax > maxsample) {
        delete m_items.take(prevMax);
        --prevMax;
    }

    // Show items
    int z = 0;
    for (int i = maxsample-1; i >= minsample; --i) {
        QDeclarativeItem *item = 0;
        item = m_items.value(i);
        bool creating = false;
        if (!item) {
            QDeclarativeContext *ctxt = new QDeclarativeContext(qmlContext(this));
            item = qobject_cast<QDeclarativeItem*>(m_delegate->beginCreate(ctxt));
            m_items.insert(i, item);
            creating = true;

            int type = m_ranges.property(i).property("type").toNumber();

            ctxt->setParent(item); //### QDeclarative_setParent_noEvent(ctxt, item); instead?
            ctxt->setContextProperty("duration", qMax(qRound(m_ranges.property(i).property("duration").toNumber()/qreal(1000)),1));
            ctxt->setContextProperty("fileName", m_ranges.property(i).property("fileName").toString());
            ctxt->setContextProperty("line", m_ranges.property(i).property("line").toNumber());
            QString label;
            QVariantList list = m_ranges.property(i).property("label").toVariant().value<QVariantList>();
            for (int i = 0; i < list.size(); ++i) {
                if (i > 0)
                    label += QLatin1Char('\n');
                QString sub = list.at(i).toString();

                //### only do rewrite for bindings...
                if (type == 3) {
                    //### don't construct in loop
                    QRegExp rewrite("\\(function \\$(\\w+)\\(\\) \\{ return (.+) \\}\\)");
                    bool match = rewrite.exactMatch(sub);
                    if (match)
                        sub = rewrite.cap(1) + ": " + rewrite.cap(2);
                }

                label += sub;
            }
            ctxt->setContextProperty("label", label);
            ctxt->setContextProperty("type", type);
            item->setParentItem(this);
        }
        if (item) {
            item->setX(m_starts.at(i)*spacing);
            item->setWidth((m_ends.at(i)-m_starts.at(i)) * spacing);
            item->setZValue(++z);
        }
        if (creating)
            m_delegate->completeCreate();
    }

    prevMin = minsample;
    prevMax = maxsample;
}
开发者ID:renatofilho,项目名称:QtCreator,代码行数:101,代码来源:timelineview.cpp


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