1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
//
// file QTGet2Strings.cc
// David Cosgrove
// AstraZeneca
// 24th April 2014
//
#include "QTGet2Strings.H"
#include <QBoxLayout>
#include <QFormLayout>
#include <QFrame>
#include <QLineEdit>
#include <QPushButton>
#include <QString>
namespace DACLIB {
// ****************************************************************************
QTGet2Strings::QTGet2Strings( QString prompt1 , QString initval1 ,
QString prompt2 , QString initval2,
QWidget *parent , Qt::WindowFlags f ) :
QDialog( parent , f ) {
build_widget( prompt1 , initval1 , prompt2 , initval2 );
}
// ****************************************************************************
void QTGet2Strings::get_values( QString &string1 , QString &string2 ) {
string1 = le1_->text();
string2 = le2_->text();
}
// ****************************************************************************
void QTGet2Strings::build_widget( QString prompt1 , QString initval1 ,
QString prompt2 , QString initval2 ) {
QVBoxLayout *vbox = new QVBoxLayout;
QFormLayout *fl = new QFormLayout;
le1_ = new QLineEdit;
fl->addRow( prompt1 , le1_ );
le1_->setText( initval1 );
le2_ = new QLineEdit;
fl->addRow( prompt2 , le2_ );
le2_->setText( initval2 );
vbox->addLayout( fl );
vbox->addWidget( build_action_box() );
setLayout( vbox );
}
// ****************************************************************************
QWidget *QTGet2Strings::build_action_box() {
QFrame *action_frame = new QFrame;
action_frame->setFrameStyle( QFrame::Box );
QHBoxLayout *hlayout = new QHBoxLayout;
QPushButton *button = new QPushButton( "Ok" );
hlayout->addWidget( button );
connect( button , SIGNAL( clicked() ) , this , SLOT( accept() ) );
button->setDefault( true );
button->setAutoDefault( true );
button = new QPushButton( "Cancel" );
hlayout->addWidget( button );
connect( button , SIGNAL( clicked() ) , this , SLOT( reject() ) );
button->setDefault( false );
button->setAutoDefault( false );
action_frame->setLayout( hlayout );
return action_frame;
}
} // EO namespace DACLIB
|