简体   繁体   中英

How to get text (Regular Expression) from QInputDialog

I want to know is there any way to get formatted text from QInputDialog that is I want integer with comma as string from Dialog . Or can we apply regular expression to QInputDialog in Text Mode . If not please suggest better way to implement this scenario.

Thank you !

Try this.

QString result = QString::number(QInputDialog::getInt(this,"title","write"))+QString(",");//we enter for example 9
qDebug() << result; //we get "9,"

Or this

QString result = QString::number(QInputDialog::getDouble(this,"title","write")).replace(".",",");//we enter for example 3.3 (3,3 in the inputDialog)
qDebug() << result;//result 3,3 (not 3.3)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM