示例#1
0
BtQmlScrollView::BtQmlScrollView(QWidget * parent, CReadDisplay* readDisplay)
    : QWidget(parent),
      m_readDisplay(readDisplay),
      m_qmlInterface(nullptr),
      m_quickWidget(new BtQuickWidget(this)),
      m_scrollBar(new QScrollBar),
      m_scrollBarPosition(0) {

    setObjectName("BtQmlScrollView");
    m_quickWidget->setObjectName("BtQuickWidget");
    m_scrollBar->setObjectName("QScrollBar");
    auto layout = new QHBoxLayout;
    layout->setContentsMargins(0,0,0,0);
    layout->addWidget(m_quickWidget);
    layout->addWidget(m_scrollBar);
    setLayout(layout);
    initScrollBar();

    m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
    m_quickWidget->show();

    QQuickItem* root = m_quickWidget->rootObject();
    m_qmlInterface = root->findChild<BtQmlInterface*>();

    BT_CONNECT(m_quickWidget, SIGNAL(referenceDropped(const QString&)),
               this, SIGNAL(referenceDropped(const QString&)));
}
示例#2
0
void ScrollView::setDirection(Direction dir)
{
    _direction = dir;
    if(_scrollBarEnabled)
    {
        removeScrollBar();
        initScrollBar();
    }
}
示例#3
0
bool ScrollView::init()
{
    if (Layout::init())
    {
        setClippingEnabled(true);
        _innerContainer->setTouchEnabled(false);
        if(_scrollBarEnabled)
        {
            initScrollBar();
        }
        return true;
    }
    return false;
}
示例#4
0
void ScrollView::setScrollBarEnabled(bool enabled)
{
    if(_scrollBarEnabled == enabled)
    {
        return;
    }

    if(_scrollBarEnabled)
    {
        removeScrollBar();
    }
    _scrollBarEnabled = enabled;
    if(_scrollBarEnabled)
    {
        initScrollBar();
    }
}