一些控制窗体的代码
FormAssets_input::FormAssets_input(QWidget *parent) :
QWidget(parent),
ui(new Ui::FormAssets_input)
{
ui->setupUi(this);
this->setWindowTitle("资产信息的输入");
this->setWindowFlags(Qt::WindowStaysOnTopHint); //窗口最前 后面可以点击
this->setWindowModality(Qt::ApplicationModal); //父窗口不可点击
this->setWindowFlags(windowFlags()&~Qt::WindowMaximizeButtonHint); // 禁止最大化按钮
this->setFixedSize(this->width(),this->height()); //禁止调整大小
this->show();
//限制只能输入数字
QRegExp rx("^(-?[0]|-?[1-9][0-9]{0,5})(?:\\.\\d{1,4})?$|(^\\t?$)");
QRegExpValidator *pReg = new QRegExpValidator(rx, this);
ui->txtAssetsPrice->setValidator(pReg);
ui->txtAssetsAmount->setValidator(pReg);
//0, 1000为输入的数字值范围
ui->txtAssetsQTY->setValidator(new QIntValidator(0, 9999, this));
ui->DtAssetsDate->setDate(QDate::currentDate());
//通过查询 将字段列表出来
QString SQL="";
QSqlQuery query(mySQL::cn); //查询 表并输出,测试能否正常操作数据库
SQL.append("SELECT DISTINCT asset_type FROM asset_details ");
SQL.append(" where ");
SQL.append(" type_id='");
SQL.append(mySQL::TypeId);
SQL.append("' ");
query.exec(SQL);
while(query.next()){
ui->cmbAssetsType->addItem(query.value("asset_type").toString());
}
登录后可发表评论
点击登录