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&))); }
void ScrollView::setDirection(Direction dir) { _direction = dir; if(_scrollBarEnabled) { removeScrollBar(); initScrollBar(); } }
bool ScrollView::init() { if (Layout::init()) { setClippingEnabled(true); _innerContainer->setTouchEnabled(false); if(_scrollBarEnabled) { initScrollBar(); } return true; } return false; }
void ScrollView::setScrollBarEnabled(bool enabled) { if(_scrollBarEnabled == enabled) { return; } if(_scrollBarEnabled) { removeScrollBar(); } _scrollBarEnabled = enabled; if(_scrollBarEnabled) { initScrollBar(); } }