本文整理汇总了C++中QLayout::parentWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ QLayout::parentWidget方法的具体用法?C++ QLayout::parentWidget怎么用?C++ QLayout::parentWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLayout
的用法示例。
在下文中一共展示了QLayout::parentWidget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: widgetSelected
void WidgetInspector::widgetSelected(const QModelIndex &index)
{
if (index.isValid()) {
QObject *obj = index.data(ObjectModel::ObjectRole).value<QObject*>();
QWidget *widget = qobject_cast<QWidget*>(obj);
QLayout* layout = qobject_cast<QLayout*>(obj);
if (!widget && layout) {
widget = layout->parentWidget();
}
ui->widgetPropertyWidget->setObject(obj);
ui->widgetPreviewWidget->setWidget(widget);
setActionsEnabled(widget != 0);
if (widget && qobject_cast<QDesktopWidget*>(widget) == 0) {
m_overlayWidget->placeOn(widget);
} else {
m_overlayWidget->placeOn(0);
}
} else {
ui->widgetPropertyWidget->setObject(0);
ui->widgetPreviewWidget->setWidget(0);
m_overlayWidget->placeOn(0);
setActionsEnabled(false);
}
}
示例2: data
QVariant WidgetTreeModel::data(const QModelIndex &index, int role) const
{
if (index.isValid() && role == Qt::ForegroundRole) {
QObject *obj = index.data(ObjectModel::ObjectRole).value<QObject*>();
QWidget *widget = qobject_cast<QWidget*>(obj);
if (!widget) {
QLayout *layout = qobject_cast<QLayout*>(obj);
if (layout) {
widget = layout->parentWidget();
}
}
if (widget && !widget->isVisible()) {
return qApp->palette().color(QPalette::Disabled, QPalette::Text);
}
}
return QSortFilterProxyModel::data(index, role);
}
示例3:
QWidget *WidgetInspector::selectedWidget() const
{
const QModelIndexList indexes = ui->widgetTreeView->selectionModel()->selectedRows();
if (indexes.isEmpty()) {
return 0;
}
const QModelIndex index = indexes.first();
if (index.isValid()) {
QObject *obj = index.data(ObjectModel::ObjectRole).value<QObject*>();
QWidget *widget = qobject_cast<QWidget*>(obj);
QLayout* layout = qobject_cast<QLayout*>(obj);
if (!widget && layout) {
widget = layout->parentWidget();
}
return widget;
}
return 0;
}