本文整理汇总了C++中QTabWidget::setUpdatesEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ QTabWidget::setUpdatesEnabled方法的具体用法?C++ QTabWidget::setUpdatesEnabled怎么用?C++ QTabWidget::setUpdatesEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTabWidget
的用法示例。
在下文中一共展示了QTabWidget::setUpdatesEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dropEvent
void QtDNDTabBar::dropEvent(QDropEvent* dropEvent) {
QtDNDTabBar* sourceTabBar = dynamic_cast<QtDNDTabBar*>(dropEvent->source());
if (sourceTabBar && dropEvent->mimeData() && dropEvent->mimeData()->data("action") == QByteArray("application/tab-detach")) {
QtDNDTabBar* source = dynamic_cast<QtDNDTabBar*>(dropEvent->source());
int targetTabIndex = tabAt(dropEvent->pos());
QRect rect = tabRect(targetTabIndex);
if (targetTabIndex >= 0 && (dropEvent->pos().x() - rect.left() - rect.width()/2 > 0)) {
targetTabIndex++;
}
QWidget* tab = source->getDragWidget();
assert(tab);
QTabWidget* targetTabWidget = dynamic_cast<QTabWidget*>(parentWidget());
QString tabText = source->getDragText();
/*
* When you add a widget to an empty QTabWidget, it's automatically made the current widget.
* Making the widget the current widget, widget->show() is called for the widget. Directly reacting
* to that event, and adding the widget again to the QTabWidget results in undefined behavior. For
* example the tab label is shown but the widget is neither has the old nor in the new QTabWidget as
* parent. Blocking signals on the QWidget to be added to a QTabWidget prevents this behavior.
*/
targetTabWidget->setUpdatesEnabled(false);
tab->blockSignals(true);
targetTabWidget->insertTab(targetTabIndex, tab, tabText);
dropEvent->acceptProposedAction();
tab->blockSignals(false);
targetTabWidget->setUpdatesEnabled(true);
onDropSucceeded();
}
}