コード例 #1
0
void dtkComposerPathPrivate::clear(void)
{   
    QLayoutItem *child;
    
    while ((child = layout->takeAt(0)) != 0) {
        delete child->widget();
        delete child;
    }
}
コード例 #2
0
void QgsFieldExpressionWidget::setLeftHandButtonStyle( bool isLeft )
{
  QHBoxLayout* layout = dynamic_cast<QHBoxLayout*>( this->layout() );
  if ( isLeft )
  {
    QLayoutItem* item = layout->takeAt( 1 );
    layout->insertWidget( 0, item->widget() );
  }
  else
    layout->addWidget( mCombo );
}
コード例 #3
0
ファイル: ctkColorDialog.cpp プロジェクト: phfr83/CTK
//------------------------------------------------------------------------------
void ctkColorDialogPrivate::init()
{
  Q_Q(ctkColorDialog);
  QVBoxLayout* mainLay = qobject_cast<QVBoxLayout*>(q->layout());
  QHBoxLayout* topLay = qobject_cast<QHBoxLayout*>(mainLay->itemAt(0)->layout());
  QVBoxLayout* leftLay = qobject_cast<QVBoxLayout*>(topLay->takeAt(0)->layout());
  
  leftLay->setParent(0);
  this->BasicTab = new QWidget(q);
  this->BasicTab->setLayout(leftLay);

  this->LeftTabWidget = new QTabWidget(q);
  topLay->insertWidget(0, this->LeftTabWidget);
  this->LeftTabWidget->addTab(this->BasicTab, QObject::tr("Basic"));
}
コード例 #4
0
void tst_QBoxLayout::sizeConstraints()
{
    QWidget *window = new QWidget;
    QHBoxLayout *lay = new QHBoxLayout;
    lay->addWidget(new QLabel("foooooooooooooooooooooooooooooooooooo"));
    lay->addWidget(new QLabel("baaaaaaaaaaaaaaaaaaaaaaaaaaaaaar"));
    lay->setSizeConstraint(QLayout::SetFixedSize);
    window->setLayout(lay);
    window->show();
    QApplication::processEvents();
    QSize sh = window->sizeHint();
    lay->takeAt(1);
    QVERIFY(sh.width() >= window->sizeHint().width() &&
            sh.height() >= window->sizeHint().height());

}
コード例 #5
0
ファイル: ctkColorDialog.cpp プロジェクト: Koki-Shimizu/CTK
//------------------------------------------------------------------------------
void ctkColorDialogPrivate::init()
{
  Q_Q(ctkColorDialog);
  QVBoxLayout* mainLay = qobject_cast<QVBoxLayout*>(q->layout());
  QHBoxLayout* topLay = qobject_cast<QHBoxLayout*>(mainLay->itemAt(0)->layout());
  QVBoxLayout* leftLay = qobject_cast<QVBoxLayout*>(topLay->takeAt(0)->layout());
  
  leftLay->setParent(0);
  this->BasicTab = new QWidget(q);
  this->BasicTab->setLayout(leftLay);

  this->LeftTabWidget = new QTabWidget(q);
  topLay->insertWidget(0, this->LeftTabWidget);
  this->LeftTabWidget->addTab(this->BasicTab, QObject::tr("Basic"));
  
  // If you use a ctkColorDialog, it's probably because you have tabs to add
  // into. Which means that you are likely to want to resize the dialog as
  // well.
  q->setSizeGripEnabled(true);
  q->layout()->setSizeConstraint(QLayout::SetDefaultConstraint);

  QObject::connect(q, SIGNAL(currentColorChanged(QColor)),
                   q, SLOT(resetColorName()));
}
コード例 #6
0
void TextFormatButtons::init(Buttons buttons)
{
  QHBoxLayout *layout = (QHBoxLayout*)this->layout();
  QLayoutItem *child;
  while ((child = layout->takeAt(0)) != 0){
    if (child->widget())
      delete child->widget();
  }

  QFont font = QFont();
  int btnSize = 32;
#ifdef Q_OS_MAC
  btnSize = 38;
#endif
  if (buttons == Legend || buttons == TexLegend){
    QPushButton *buttonCurve = new QPushButton( QPixmap(":/lineSymbol.png"), QString());
    buttonCurve->setFixedWidth(btnSize);
    buttonCurve->setFixedHeight(btnSize);
    buttonCurve->setFont(font);
    layout->addWidget(buttonCurve);
    connect( buttonCurve, SIGNAL(clicked()), this, SLOT(addCurve()) );
  }

  QPushButton *buttonSubscript = new QPushButton(QPixmap(":/index.png"), QString());
  buttonSubscript->setFixedWidth(btnSize);
  buttonSubscript->setFixedHeight(btnSize);
  buttonSubscript->setFont(font);
  layout->addWidget(buttonSubscript);
  connect( buttonSubscript, SIGNAL(clicked()), this, SLOT(addSubscript()) );

  QPushButton *buttonSuperscript = new QPushButton(QPixmap(":/exp.png"), QString());
  buttonSuperscript->setFixedWidth(btnSize);
  buttonSuperscript->setFixedHeight(btnSize);
  buttonSuperscript->setFont(font);
  layout->addWidget(buttonSuperscript);
  connect( buttonSuperscript, SIGNAL(clicked()), this, SLOT(addSuperscript()));

  if (buttons == Equation || buttons == TexLegend){
    QPushButton *buttonFraction = new QPushButton(QPixmap(":/fraction.png"), QString());
    buttonFraction->setFixedWidth(btnSize);
    buttonFraction->setFixedHeight(btnSize);
    buttonFraction->setFont(font);
    layout->addWidget(buttonFraction);
    connect(buttonFraction, SIGNAL(clicked()), this, SLOT(addFraction()));

    QPushButton *buttonSquareRoot = new QPushButton(QPixmap(":/square_root.png"), QString());
    buttonSquareRoot->setFixedWidth(btnSize);
    buttonSquareRoot->setFixedHeight(btnSize);
    buttonSquareRoot->setFont(font);
    layout->addWidget(buttonSquareRoot);
    connect(buttonSquareRoot, SIGNAL(clicked()), this, SLOT(addSquareRoot()));
  }

  QPushButton *buttonLowerGreek = new QPushButton(QString(QChar(0x3B1)));
  buttonLowerGreek->setFont(font);
  buttonLowerGreek->setFixedWidth(btnSize);
  buttonLowerGreek->setFixedHeight(btnSize);
  layout->addWidget(buttonLowerGreek);
  connect( buttonLowerGreek, SIGNAL(clicked()), this, SLOT(showLowerGreek()));

  QPushButton *buttonUpperGreek = new QPushButton(QString(QChar(0x393)));
  buttonUpperGreek->setFont(font);
  buttonUpperGreek->setFixedWidth(btnSize);
  buttonUpperGreek->setFixedHeight(btnSize);
  layout->addWidget(buttonUpperGreek);
  connect( buttonUpperGreek, SIGNAL(clicked()), this, SLOT(showUpperGreek()));

  QPushButton *buttonArrowSymbols = new QPushButton(QString(QChar(0x2192)));
  buttonArrowSymbols->setFont(font);
  buttonArrowSymbols->setFixedWidth(btnSize);
  buttonArrowSymbols->setFixedHeight(btnSize);
  layout->addWidget(buttonArrowSymbols);
  connect( buttonArrowSymbols, SIGNAL(clicked()), this, SLOT(showArrowSymbols()));

  QPushButton *buttonMathSymbols = new QPushButton(QString(QChar(0x222B)));
  buttonMathSymbols->setFont(font);
  buttonMathSymbols->setFixedWidth(btnSize);
  buttonMathSymbols->setFixedHeight(btnSize);
  layout->addWidget(buttonMathSymbols);
  connect( buttonMathSymbols, SIGNAL(clicked()), this, SLOT(showMathSymbols()));

  if (buttons != Plot3D && buttons != Equation && buttons != TexLegend){
    font = this->font();
    font.setBold(true);

    QPushButton *buttonBold = new QPushButton(tr("B","Button bold"));
    buttonBold->setFont(font);
    buttonBold->setFixedWidth(btnSize);
    buttonBold->setFixedHeight(btnSize);
    layout->addWidget(buttonBold);
    connect( buttonBold, SIGNAL(clicked()), this, SLOT(addBold()));

    font = this->font();
    font.setItalic(true);

    QPushButton *buttonItalics = new QPushButton(tr("It","Button italics"));
    buttonItalics->setFont(font);
    buttonItalics->setFixedWidth(btnSize);
    buttonItalics->setFixedHeight(btnSize);
    layout->addWidget(buttonItalics);
    connect( buttonItalics, SIGNAL(clicked()), this, SLOT(addItalics()));

    font = this->font();
    font.setUnderline(true);

    QPushButton *buttonUnderline = new QPushButton(tr("U","Button underline"));
    buttonUnderline->setFont(font);
    buttonUnderline->setFixedWidth(btnSize);
    buttonUnderline->setFixedHeight(btnSize);
    layout->addWidget(buttonUnderline);
    layout->addStretch();
    connect( buttonUnderline, SIGNAL(clicked()), this, SLOT(addUnderline()));
  } else
    layout->addStretch();
}