コード例 #1
0
void FormBase::addLineEdits(QWidget *parent, QStringList texts, HashLineEdit &hle, int lineEditWidth, QStringList names)
{
	QGridLayout *layout = static_cast<QGridLayout *>(parent->layout());
	
	for (uint i = 0; i < texts.count(); i++)
	{
		QLabel *labTmp = new QLabel(texts[i], parent);
		KLineEdit *lineEditTmp = new KLineEdit(parent, names[i]);
		lineEditTmp->setMaximumWidth(lineEditWidth);
		lineEditTmp->resize( lineEditTmp->height(), lineEditWidth);
		labTmp->setBuddy(lineEditTmp);

		int row = i + layout->numRows();
		layout->addWidget(labTmp, row, 0);
		layout->addWidget(lineEditTmp, row, 1);
		
		hle.insert(names[i], lineEditTmp);
	}
}
コード例 #2
0
TesterTestPage::TesterTestPage (QWidget *p) : QWidget (p)
{
  fieldList.append(tr("Open"));
  fieldList.append(tr("Close"));
  fieldList.append(tr("Mid Point"));

  QHBoxLayout *hbox = new QHBoxLayout(this);
  hbox->setMargin(5);
  hbox->setSpacing(10);

  // left side grid

  QGridLayout *grid = new QGridLayout(hbox);
  grid->setColStretch(1, 1);
  grid->setSpacing(5);

  // trades area  

  tradeLong = new QCheckBox(tr("Long"), this);
  grid->addWidget(tradeLong, 0, 0);

  tradeShort = new QCheckBox(tr("Short"), this);
  grid->addWidget(tradeShort, 1, 0);

  QLabel *label = new QLabel(tr("Trade Delay"), this);
  grid->addWidget(label, 2, 0);
    
  tradeDelay = new QSpinBox(1, 999999, 1, this);
  tradeDelay->setValue(1);
  grid->addWidget(tradeDelay, 2, 1);

  grid->setRowSpacing(grid->numRows(), 25);

  // account area

  label = new QLabel(tr("Account Balance"), this);
  grid->addWidget(label, 4, 0);

  account = new QSpinBox(0, 999999, 1, this);
  account->setValue(10000);
  grid->addWidget(account, 4, 1);
  
  label = new QLabel(tr("Futures Margin"), this);
  grid->addWidget(label, 5, 0);

  margin = new QSpinBox(0, 999999, 1, this);
  grid->addWidget(margin, 5, 1);
  
  label = new QLabel(tr("Volume %"), this);
  grid->addWidget(label, 6, 0);

  volumePercent = new QSpinBox(0, 100, 1, this);
  grid->addWidget(volumePercent, 6, 1);

  grid->setRowSpacing(grid->numRows(), 25);

  // commission area

  commissionType = new QCheckBox(tr("Use Commission %"), this);
  grid->addWidget(commissionType, 8, 0);

  label = new QLabel(tr("Entry"), this);
  grid->addWidget(label, 9, 0);

  QDoubleValidator *dv = new QDoubleValidator(0, 99999999.0, 4, this, 0);
  entryCom = new QLineEdit(QString::number(10), this);
  entryCom->setValidator(dv);
  grid->addWidget(entryCom, 9, 1);

  label = new QLabel(tr("Exit"), this);
  grid->addWidget(label, 10, 0);

  QDoubleValidator *dv2 = new QDoubleValidator(0, 99999999.0, 4, this, 0);
  exitCom = new QLineEdit(QString::number(10), this);
  exitCom->setValidator(dv2);
  grid->addWidget(exitCom, 10, 1);

  grid->setRowStretch(grid->numRows() + 1, 1);

  // vline sperarator
  
  QFrame *line = new QFrame(this);
  line->setFrameStyle(QFrame::VLine | QFrame::Plain);
  hbox->addWidget(line);

  // right side grid

  grid = new QGridLayout(hbox);
  grid->setColStretch(1, 1);
  grid->setSpacing(5);

  // test area

  label = new QLabel(tr("Symbol"), this);
  grid->addWidget(label, 0, 0);

  Config config;
  QString s, s2;
  config.getData(Config::DataPath, s);
  symbolButton = new SymbolButton(this, s, s2);
  connect(symbolButton, SIGNAL(symbolChanged()), this, SLOT(symbolButtonPressed()));
  grid->addWidget(symbolButton, 0, 1);
  
  label = new QLabel(tr("Bar Length"), this);
  grid->addWidget(label, 1, 0);
  
  BarData bd(s);
  barLength = new QComboBox(this);
  bd.getBarLengthList(barLengthList);
  barLength->insertStringList(barLengthList, -1);
  barLength->setCurrentItem(6);
  grid->addWidget(barLength, 1, 1);

  label = new QLabel(tr("Bars"), this);
  grid->addWidget(label, 2, 0);
  
  bars = new QSpinBox(1, 99999999, 1, this);
  bars->setValue(275);
  grid->addWidget(bars, 2, 1);

  label = new QLabel(tr("Entry/Exit Price"), this);
  grid->addWidget(label, 3, 0);
  
  priceField = new QComboBox(this);
  priceField->insertStringList(fieldList,-1);
  grid->addWidget(priceField, 3, 1);

  grid->setRowStretch(grid->numRows() + 1, 1);
}
コード例 #3
0
    void FieldLineEdit::setupGUI( const char *name )
    {
        Settings * settings = Settings::self();

        char * subname = NULL;
        if ( name != NULL )
            subname = new char[ strlen( name ) + 20 ];

        if ( subname != NULL )
        {
            strcpy( subname, name );
            strcat( subname, "_pbstring" );
        }
        m_pushButtonString = new QPushButton( this, subname );
        m_pushButtonString->setIconSet( QIconSet( SmallIcon( "flag" ) ) );
        m_pushButtonString->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
        m_pushButtonString->setToggleButton( TRUE );
        QToolTip::add( m_pushButtonString, QString( i18n( "Set '%1' to be a string key" ) ).arg( m_caption ) );
        connect( m_pushButtonString, SIGNAL( clicked() ), this, SLOT( slotStringToggled() ) );

        if ( subname != NULL )
        {
            strcpy( subname, name );
            strcat( subname, "_pbcomplex" );
        }
        m_pushButtonComplex = new QPushButton( this, subname );
        m_pushButtonComplex->setIconSet( QIconSet( SmallIcon( "leftjust" ) ) );
        m_pushButtonComplex->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
        QToolTip::add( m_pushButtonComplex, QString( i18n( "Edit '%1' as a concatenated value" ) ).arg( m_caption ) );
        connect( m_pushButtonComplex, SIGNAL( clicked() ), this, SLOT( slotComplexClicked() ) );

        QGridLayout * layout = NULL;
        switch ( m_inputType )
        {
        case itSingleLine:
            {
                layout = new QGridLayout( this, 2, 3, 0, KDialog::spacingHint() );
                if ( subname != NULL )
                {
                    strcpy( subname, name );
                    strcat( subname, "_lineedit" );
                }
                m_lineEdit = new KLineEdit( this, subname );
                m_lineEdit->setReadOnly( m_isReadOnly );
                if ( settings->editing_UseSpecialFont )
                    m_lineEdit->setFont( settings->editing_SpecialFont );
                layout->addWidget( m_lineEdit, 0, 0 );
                setFocusProxy( m_lineEdit );
                layout->addWidget( m_pushButtonString, 0, 1 );
                layout->addWidget( m_pushButtonComplex, 0, 2 );
                QWidget::setTabOrder( m_lineEdit, m_pushButtonString );
            }
            break;
        case itMultiLine:
            {
                layout = new QGridLayout( this, 3, 2, 0, KDialog::spacingHint() );
                layout->setRowStretch( 2, 1 );
                if ( subname != NULL )
                {
                    strcpy( subname, name );
                    strcat( subname, "_textedit" );
                }
                m_textEdit = new QTextEdit( this, subname );
                m_textEdit->setReadOnly( m_isReadOnly );
                if ( settings->editing_UseSpecialFont )
                    m_textEdit->setFont( settings->editing_SpecialFont );
                layout->addMultiCellWidget( m_textEdit, 0, 2, 0, 0 );
                setFocusProxy( m_textEdit );
                layout->addWidget( m_pushButtonString, 0, 1 );
                layout->addWidget( m_pushButtonComplex, 1, 1 );
                QWidget::setTabOrder( m_textEdit, m_pushButtonString );
            }
            break;
        }

        QWidget::setTabOrder( m_pushButtonString, m_pushButtonComplex );
        layout->setRowStretch( layout->numRows() - 1, 1 );

        if ( subname != NULL )
            delete subname;

        enableSignals( TRUE );
    }