QT5.6 开发笔记

1.给菜单栏添加Css样式
ui->menuBar->setStyleSheet(
		" QMenu {\
                background-color: white; \
                border: 1px solid white;\
            }\
            QMenu::item {\
                \
                background-color: transparent;\
                padding:4px 25px;\
                margin:0px 4px;\
   border-bottom:1px solid #DBDBDB;\
            }\
            QMenu::item:selected { \
                background-color: #2dabf9;\
                font-color:black\
            }"

	);
2.给lineEdit 添加正则表达式限制
QRegExp regx("[0-9]+$");
	QValidator *validator = new QRegExpValidator(regx, ui->lineEdit);
	ui->lineEdit->setValidator(validator);

3.多文件的读取  CSV格式文件  以及弹出提示框  中文处理

void RamanSpectrum::ImportPositionMapping()
{
	//QVector<QPointF> XPointPosition;
	QString path = QFileDialog::getOpenFileName(this, QStringLiteral("选择文件"), "../", tr("(*).csv"));
	QFile csvFile(path);
	QFileInfo fi(path);

	if (csvFile.open(QIODevice::ReadWrite))
	{
		QTextStream stream(&csvFile);
		while (!stream.atEnd())
		{
			QString xyString = stream.readLine();
			double x = xyString.section(',', 0, 0).toDouble();
			double y = xyString.section(',', 1, 1).toDouble();
			QPointF point;
			point.setX(x);
			point.setY(y);
			XPositionMap.push_back(point);
		}
	}
	if (XPositionMap.size()!=0)
	{
		QMessageBox::information(NULL, QStringLiteral("小贴士"), QStringLiteral("导入位置信息成功!"), QMessageBox::Ok | QMessageBox::No, QMessageBox::Ok);
	}
	else
	{
		QMessageBox::information(NULL, QStringLiteral("小贴士"), QStringLiteral("导入位置信息失败,请重新导入!"), QMessageBox::Ok | QMessageBox::No, QMessageBox::Ok);
		return;
	}
	

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值