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


C++ QLayoutItem::widget方法代码示例

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


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

示例1: ForwardMouseClickEvent

    void HoveringButtonsController::ForwardMouseClickEvent(float x, float y)
    { 
        //To widgetspace
        float x_widgetspace = x*(float)this->width();
        float y_widgetspace = y*(float)this->height();

        QPoint pos(x_widgetspace,y_widgetspace);

        QMouseEvent e(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
        QApplication::sendEvent(this, &e);
        //Iterate through buttons and check if they are pressed 
        for(int i = 0; i< layout()->count();i++)
        {
            
            QLayoutItem* item = layout()->itemAt(i);
            QAbstractButton *button = dynamic_cast<QAbstractButton*>(item->widget());
            if(button)
            {

                if(button->rect().contains(button->mapFromParent(pos)))
                {
                    QMouseEvent e(QEvent::MouseButtonPress, pos - button->pos(),pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                    QApplication::sendEvent(button, &e);
                }
            }
        }

        
    }
开发者ID:Chiru,项目名称:naali,代码行数:29,代码来源:HoveringButtonsController.cpp

示例2: listItems

QStringList ContainerAreaLayout::listItems() const
{
    QStringList items;
    for (ItemList::const_iterator it = m_items.constBegin();
         it != m_items.constEnd(); ++it)
    {
        QLayoutItem* item = (*it)->item;
        BaseContainer* container = dynamic_cast<BaseContainer*>(item->widget());

        if (!container)
        {
            continue;
        }

        AppletContainer* applet = dynamic_cast<AppletContainer*>(container);
        if (applet)
        {
            items.append(applet->info().desktopFile());
        }
        else
        {
            // button containers don't give us anything useful that isn't
            // i18n'd (e.g. all service buttons and url buttons simply report
            // "URL" as their tileName()) which would require that we
            // extend PanelButton to be more expressive to get something more
            // instead i just cop'd out and use the visible name. good enough.
            items.append(container->visibleName());
        }
    }

    return items;
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例3: switchPropertiesEditorWidget

void ActionManagerDialog::switchPropertiesEditorWidget(QWidget* widget)
{
    QLayout *layout = mPropertiesEditorParentWidget->layout();
    if (! layout)
        return;

    QLayoutItem* item = layout->takeAt(0);
    if (item && item->widget())
        item->widget()->hide();

    if (widget) {
        layout->addWidget(widget);
        if (widget->isHidden())
            widget->show();
    }
}
开发者ID:fr33mind,项目名称:Belle,代码行数:16,代码来源:actionmanagerdialog.cpp

示例4: setIconSize

void QToolBar::setIconSize(const QSize &iconSize)
{
    Q_D(QToolBar);
    QSize sz = iconSize;
    if (!sz.isValid()) {
        QMainWindow *mw = qobject_cast<QMainWindow *>(parentWidget());
        if (mw && mw->layout()) {
            QLayout *layout = mw->layout();
            int i = 0;
            QLayoutItem *item = 0;
            do {
                item = layout->itemAt(i++);
                if (item && (item->widget() == this))
                    sz = mw->iconSize();
            } while (!sz.isValid() && item != 0);
        }
    }
    if (!sz.isValid()) {
        const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this);
        sz = QSize(metric, metric);
    }
    if (d->iconSize != sz) {
        d->iconSize = sz;
        setMinimumSize(0, 0);
        emit iconSizeChanged(d->iconSize);
    }
    d->explicitIconSize = iconSize.isValid();

    d->layout->invalidate();
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例5: clearLayout

void MainWindow::clearLayout(QLayout* layout) {
    QLayoutItem* item;
    while ((item = layout->takeAt(0)) != nullptr) {
        delete item->widget();
        delete item;
    }
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例6: clearImage

void TestingTaskWidget::clearImage() {
    QLayoutItem* item;
    while((item = ui->verticalLayout_2->takeAt(0)) != NULL ) {
        delete item->widget();
        delete item;
    }
}
开发者ID:EPecherkin,项目名称:Exams_v2,代码行数:7,代码来源:testingtaskwidget.cpp

示例7: DisplayAnswer

void ShowWidget::DisplayAnswer()
{
    Table t = this->table;

    QLayoutItem *child;
    while((child = gridlayout->takeAt(0)) != 0)
    {
        delete child->widget();
        delete child;
    }

    for(int i=0;i<t.n;i++)
        for(int j=0;j<t.n;j++)
        {
            QLabel *label = new QLabel();
            QPixmap pmap(":/new/prefix1/Back");
            QPainter painter1;
            QFont font1("Arial",13,QFont::Bold,false);
            QFont font2("Arial",9,QFont::Bold,false);
            painter1.begin(&pmap);
            if(t.n<10) painter1.setFont(font1);
            else painter1.setFont(font2);
            painter1.setPen(Qt::blue);
            painter1.drawText(3,3,20,20,Qt::AlignCenter,QString::number(t.data[i][j],10));//将数字转化成输出
            painter1.end();
            label->setPixmap(pmap);
            gridlayout->addWidget(label,i,j);
        }

    this->setWindowTitle(QString::number(t.n,10) + tr("阶魔方阵"));
    this->show();
}
开发者ID:Mr-Phoebe,项目名称:QT-learning,代码行数:32,代码来源:showwidget.cpp

示例8: clearRotationGroupTasks

void RotationGroupTaskListView::clearRotationGroupTasks(){
    QLayoutItem *item;
    while((item = listContentLayout->takeAt(0)) != NULL){
        delete item->widget();
        delete item;
    }
}
开发者ID:Frank112,项目名称:BP38Ergonomie,代码行数:7,代码来源:rotationgrouptasklistview.cpp

示例9: handleDisconnect

void VirshGui::handleDisconnect()
{
    while (ui->vmListTable->rowCount() > 0) {
        ui->vmListTable->removeRow(0);
    }

    ui->startStopButton->setText("keine Aktion");
    ui->startStopButton->setDisabled(true);
    ui->shutdownButton->setDisabled(true);
    ui->rebootButton->setDisabled(true);
    ui->virtViewerButton->setDisabled(true);

    while (ui->snapshotsTabLayout->count() > 0) {
        QLayoutItem *item = ui->snapshotsTabLayout->takeAt(0);
        delete item->widget();
        delete item;
    }

    ui->xmlDisplay->setText("");
    ui->vmnameLabel->setText("");
    ui->statusLabel->setText("");
    ui->memoryLabel->setText("");
    ui->cpucountLabel->setText("");
    ui->typeLabel->setText("");
    ui->archLabel->setText("");
    ui->bootdevLabel->setText("");
    ui->hvFeaturesLabel->setText("");
    ui->cpuFeaturesLabel->setText("");

    ui->refreshVmList->setDisabled(true);

    QMessageBox disconnectBox;
    disconnectBox.setText("Die SSH Verbindung wurde beendet.");
    disconnectBox.exec();
}
开发者ID:SteveCharleston,项目名称:virsh-gui,代码行数:35,代码来源:virshgui.cpp

示例10:

QWidget *QLayoutItemProto::widget()
{
  QLayoutItem *item = qscriptvalue_cast<QLayoutItem*>(thisObject());
  if (item)
    return item->widget();
  return 0;
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例11: updateLegend

void TimeAnalysisWidget::updateLegend()
{
    std::vector<std::string> &labels = _selectedScalar->labels();

    // removinb previous legend
    QFormLayout *layout = (QFormLayout *)_ui->legendGroupBox->layout();
    QLayoutItem *child;
    while (layout->count()!=0 && (child = layout->takeAt(0)) != 0) {
        child->widget()->deleteLater();
        delete child;
    }

    for (unsigned i=0; i<labels.size(); ++i) {
        QLabel *colorLabel = new QLabel;
        colorLabel->setAutoFillBackground(true);
        colorLabel->setMinimumSize(70, 15);
        QPalette palette = colorLabel->palette();

        float denom = _selectedScalar->max() - _selectedScalar->min();
        float normalizedValue = ( i - _selectedScalar->min() ) / ( denom == 0 ? 1.f : denom );

        palette.setColor(colorLabel->backgroundRole(), _ui->projectionWidget->colorScale()->getColor(normalizedValue));
        colorLabel->setPalette(palette);

        layout->addRow(new QLabel(labels[i].c_str()), colorLabel);
    }

    repaint();
}
开发者ID:Rambo2015,项目名称:TaxiVis,代码行数:29,代码来源:timeanalysiswidget.cpp

示例12: populateImageEncodings

void QgsArcGisServiceSourceSelect::populateImageEncodings( const QStringList &availableEncodings )
{
  QLayoutItem *item = nullptr;
  while ( ( item = gbImageEncoding->layout()->takeAt( 0 ) ) )
  {
    delete item->widget();
    delete item;
  }
  bool first = true;
  QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
  foreach ( const QString &encoding, availableEncodings )
  {
    bool supported = false;
    foreach ( const QByteArray &fmt, supportedFormats )
    {
      if ( encoding.startsWith( fmt, Qt::CaseInsensitive ) )
      {
        supported = true;
      }
    }
    if ( !supported )
    {
      continue;
    }

    QRadioButton *button = new QRadioButton( encoding, this );
    button->setChecked( first );
    gbImageEncoding->layout()->addWidget( button );
    mImageEncodingGroup->addButton( button );
    first = false;
  }
开发者ID:anitagraser,项目名称:QGIS,代码行数:31,代码来源:qgsarcgisservicesourceselect.cpp

示例13: doLayout

int LayoutVisitorsTray::doLayout(const QRect &rect, bool testOnly) const
{
    int left, top, right, bottom;
    getContentsMargins(&left, &top, &right, &bottom);
    QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
    int x = effectiveRect.x();
    int y = effectiveRect.y();
    int lineHeight = 0;

    QLayoutItem *item;
    foreach (item, itemList) {
        QWidget *wid = item->widget();
        int spaceX = horizontalSpacing();
        if (spaceX == -1)
            spaceX = wid->style()->layoutSpacing(
                QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
        int spaceY = verticalSpacing();
        if (spaceY == -1)
            spaceY = wid->style()->layoutSpacing(
                QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);

        int nextX = x + item->sizeHint().width() + spaceX;
        if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
            x = effectiveRect.x();
            y = y + lineHeight + spaceY;
            nextX = x + item->sizeHint().width() + spaceX;
            lineHeight = 0;
        }

        if (!testOnly)
            item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));

        x = nextX;
        lineHeight = qMax(lineHeight, item->sizeHint().height());
    }
开发者ID:cscart,项目名称:livehelp,代码行数:35,代码来源:LayoutVisitorsTray.cpp

示例14: updatePluginInformations

/** ***************************************************************************/
void SettingsWidget::updatePluginInformations(const QModelIndex & current) {
    // Hidde the placehodler text
    QLayoutItem *i = ui.widget_pluginInfos->layout()->takeAt(1);
    delete i->widget();
    delete i;

    if (extensionManager_->extensionSpecs()[current.row()]->state() == ExtensionSpec::State::Loaded){
        Extension *extension = dynamic_cast<Extension*>(extensionManager_->extensionSpecs()[current.row()]->instance());
        if (!extension){
            qWarning() << "Cannot cast an object of extension spec to an extension!";
            return; // Should no happen
        }
        QWidget *pw = extension->widget();
        if ( pw->layout() != nullptr)
            pw->layout()->setMargin(0);
        ui.widget_pluginInfos->layout()->addWidget(pw);// Takes ownership
        ui.label_pluginTitle->setText(extension->name());
        ui.label_pluginTitle->show();
    }
    else{
        QString msg("Plugin not loaded.\n%1");
        QLabel *lbl = new QLabel(msg.arg(extensionManager_->extensionSpecs()[current.row()]->lastError()));
        lbl->setEnabled(false);
        lbl->setAlignment(Qt::AlignCenter);
        ui.widget_pluginInfos->layout()->addWidget(lbl);
        ui.label_pluginTitle->hide();
    }
}
开发者ID:BoltsJ,项目名称:albert,代码行数:29,代码来源:settingswidget.cpp

示例15: setWidgetStyle

void VCSlider::setWidgetStyle(SliderWidgetStyle mode)
{
    if (mode == m_widgetMode)
        return;

    if (mode == WKnob && m_slider)
    {
        qDebug() << "Switching to knob widget";
        disconnect(m_slider, SIGNAL(valueChanged(int)),
                this, SLOT(slotSliderMoved(int)));

        QLayoutItem* item;
        while ( ( item = m_hbox->takeAt( 0 ) ) != NULL )
        {
            delete item->widget();
            delete item;
        }

        m_slider = NULL;

        m_knob = new KnobWidget(this);
        m_knob->setEnabled(false);
        m_hbox->addWidget(m_knob);
        m_knob->show();
        connect(m_knob, SIGNAL(valueChanged(int)),
                this, SLOT(slotSliderMoved(int)));
    }
开发者ID:hokowa3,项目名称:qlcplus,代码行数:27,代码来源:vcslider.cpp


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