Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void QWidget::setLayout ( QLayout layout  )  [inherited]

Sets the layout manager for this widget to layout.

If there already is a layout manager installed on this widget, QWidget won't let you install another. You must first delete the existing layout manager (returned by layout()) before you can call setLayout() with the new layout.

Example:

examples/tutorials/tutorial/t10/lcdrange.cpp 0

An alternative to calling this function is to pass this widget to the layout's constructor.

The QWidget will take ownership of layout.

See also:
layout(), {Layout Classes}

Definition at line 8420 of file qwidget.cpp.

References QMetaObject::className(), QByteArray::data(), QLayout::invalidate(), QWidget::isWindow(), QLayout::layout(), QWidget::layout(), QObject::objectName, QObject::parent(), QObject::setParent(), and QString::toLocal8Bit().

Referenced by AddDialog::AddDialog(), AddressBook::AddressBook(), ApplicationsTab::ApplicationsTab(), ArrowPad::ArrowPad(), BlockingClient::BlockingClient(), ButtonWidget::ButtonWidget(), Calculator::Calculator(), CalculatorForm::CalculatorForm(), ClassInfoPage::ClassInfoPage(), Client::Client(), CodeStylePage::CodeStylePage(), ConclusionPage::ConclusionPage(), ControllerWindow::ControllerWindow(), MainWindow::createBackgroundCellWidget(), MainWindow::createCellWidget(), Window::createControls(), Window::createDatesGroupBox(), Window::createDateTimeEdits(), Window::createDoubleSpinBoxes(), Window::createFirstExclusiveGroup(), Dialog::createFormGroupBox(), Window::createGeneralOptionsGroupBox(), Dialog::createGridGroupBox(), ControllerWindow::createHintsGroupBox(), Dialog::createHorizontalGroupBox(), Window::createIconGroupBox(), MainWindow::createIconSizeGroupBox(), MainWindow::createImagesGroupBox(), Window::createNonExclusiveGroup(), Screenshot::createOptionsGroupBox(), Window::createPreviewGroupBox(), MainWindow::createPreviewGroupBox(), Window::createPushButtonGroup(), Window::createSecondExclusiveGroup(), Window::createSpinBoxes(), Window::createTextFormatsGroupBox(), MainWindow::createToolBox(), WidgetGallery::createTopLeftGroupBox(), WidgetGallery::createTopRightGroupBox(), ControllerWindow::createTypeGroupBox(), DetailsDialog::DetailsDialog(), Dialog::Dialog(), DropSiteWindow::DropSiteWindow(), EchoWindow::EchoWindow(), EvaluatePage::EvaluatePage(), FileReader::FileReader(), FindDialog::FindDialog(), GeneralTab::GeneralTab(), IconPreviewArea::IconPreviewArea(), ImageComposer::ImageComposer(), InformationWindow::InformationWindow(), LCDRange::init(), IntroPage::IntroPage(), LCDRange::LCDRange(), MainWindow::MainWindow(), NewAddressTab::NewAddressTab(), OutputFilesPage::OutputFilesPage(), PermissionsTab::PermissionsTab(), PreviewWindow::PreviewWindow(), PrintPanel::PrintPanel(), QLayout::QLayout(), QMdiSubWindow::QMdiSubWindow(), QPageSetupDialog::QPageSetupDialog(), RegisterPage::RegisterPage(), Screenshot::Screenshot(), Server::Server(), MainWindow::setupUi(), SlidersGroup::SlidersGroup(), TabDialog::TabDialog(), TableEditor::TableEditor(), TetrixWindow::TetrixWindow(), TextFinder::TextFinder(), TicTacToeDialog::TicTacToeDialog(), and WidgetGallery::WidgetGallery().

{
    if (!l) {
        qWarning("QWidget::setLayout: Cannot set layout to 0");
        return;
    }
    if (layout()) {
        if (layout() != l)
            qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a"
                     " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(),
                     objectName().toLocal8Bit().data());
        return;
    }

    QObject *oldParent = l->parent();
    if (oldParent && oldParent != this) {
        qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent",
                 l->objectName().toLocal8Bit().data(), metaObject()->className(),
                 objectName().toLocal8Bit().data());
        return;
    }

    Q_D(QWidget);
    l->d_func()->topLevel = true;
    d->layout = l;
    if (oldParent != this) {
        l->setParent(this);
        l->d_func()->reparentChildWidgets(this);
        l->invalidate();
    }

    if (isWindow() && d->maybeTopData())
        d->topData()->sizeAdjusted = false;
}


Generated by  Doxygen 1.6.0   Back to index