本文整理汇总了C++中QChar::toAscii方法的典型用法代码示例。如果您正苦于以下问题:C++ QChar::toAscii方法的具体用法?C++ QChar::toAscii怎么用?C++ QChar::toAscii使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QChar
的用法示例。
在下文中一共展示了QChar::toAscii方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testTypingValue
void testTypingValue(
SpinBoxType* sbox, QPushButton *okButton, const QString &value)
{
sbox->selectAll();
for (int i = 0; i < value.size(); ++i) {
const QChar valChar = value[i];
_keyClick(static_cast<QWidget *>(sbox), valChar.toAscii()); // ### always guaranteed to work?
if (sbox->hasAcceptableInput())
QVERIFY(okButton->isEnabled());
else
QVERIFY(!okButton->isEnabled());
}
}
示例2: isQuoteMeta
inline static bool isQuoteMeta( QChar cUnicode )
{
#if 0 // it's not worth it, especially after seeing gcc's asm output ...
static const uchar iqm[] = {
0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00
}; // \'"$
return (c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7)));
#else
char c = cUnicode.toAscii();
return c == '\\' || c == '\'' || c == '"' || c == '$';
#endif
}
示例3: modifyReference
void EnhancedPathShape::modifyReference(const QString &reference, qreal value)
{
if (reference.isEmpty())
return;
QChar c = reference[0];
if (c.toAscii() == '$') {
bool success = false;
int modifierIndex = reference.mid(1).toInt(&success);
if (modifierIndex >= 0 && modifierIndex < m_modifiers.count())
m_modifiers[modifierIndex] = value;
}
}
示例4: sendMessage
void OmaSaunalahti::sendMessage(QNetworkAccessManager* manager, QString message) {
if (message.toAscii().length()==0)
return;
this->loggedIn = false;
connect(manager, SIGNAL(finished(QNetworkReply*)), SLOT(replyFinished(QNetworkReply*)));
this->message = message;
this->messageTime = QString("%0 %1").arg(QDate::currentDate().toString("dd.MM.yyyy")).arg(QTime::currentTime().toString("hh:mm:ss.zzz"));
QChar *messageChar = this->message.data();
while (!messageChar->isNull()) {
if (messageChar->isSpace()) {
QString chr = QString("%0").arg(QString::number( messageChar->toAscii(), 16 ).toUpper());
if (chr.length()==1)
chr = "%0" + chr;
this->message = this->message.replace(messageChar->toAscii(),chr);
}
++messageChar;
}
QUrl url = QUrl(this->server);
url.addQueryItem("username",this->username);
url.addQueryItem("login","Sisään");
url.addQueryItem("password",this->password);
QNetworkRequest request;
request.setUrl(url);
QNetworkReply *reply = manager->post(request,url.toString().split("?")[1].toAscii());
url.setEncodedQuery(QByteArray());
url.addQueryItem("sender",this->sender);
url.addQueryItem("recipients",this->receiver);
url.addQueryItem("text",this->message);
url.addQueryItem("size",QString("%0").arg(this->message.toAscii().length()));
url.addQueryItem("send","Lähetä");
connect(manager, SIGNAL(finished(QNetworkReply*)), SLOT(messageSent(QNetworkReply*)));
reply = manager->post(request,url.toString().split("?")[1].toAscii());
}
示例5: loadSettings
void Settings::loadSettings(const QString & fileName, QByteArray * windowGeometry, QByteArray * windowState)
{
QString path = fileName;
if(fileName.isEmpty())
{
path = iniDefaultPath();
}
QSettings ini(path, QSettings::IniFormat);
for(ParametersMap::const_iterator iter = defaultParameters_.begin(); iter!=defaultParameters_.end(); ++iter)
{
const QString & key = iter.key();
QVariant value = ini.value(key, QVariant());
if(value.isValid())
{
QString str = value.toString();
if(str.contains(";") && str.size() != getParameter(key).toString().size())
{
// If a string list is modified, update the value
// (assuming that index < 10... one character for index)
QChar index = str.at(0);
str = getParameter(key).toString();
str[0] = index.toAscii();
value = QVariant(str);
printf("Updated list of parameter \"%s\"\n", key.toStdString().c_str());
}
setParameter(key, value);
}
}
if(windowGeometry)
{
QVariant value = ini.value("windowGeometry", QVariant());
if(value.isValid())
{
*windowGeometry = value.toByteArray();
}
}
if(windowState)
{
QVariant value = ini.value("windowState", QVariant());
if(value.isValid())
{
*windowState = value.toByteArray();
}
}
printf("Settings loaded from %s\n", path.toStdString().c_str());
}
示例6: ParseTokken
QString ParseTokken(QTextStream &in) {
static QChar last;
QChar c;
QString sum;
in >> c;
switch (c.toAscii()) {
case '(':
case ';':
case ')':
case '[':
case ']':
case '\\':
return c;
}
return "";
}
示例7: RegistHotkey
bool Settings::RegistHotkey(QWidget *window,
QChar keyValue,
Qt::KeyboardModifiers keyMod)
{
#if WIN32
WId w_handle = window ? window->winId(): 0;
int modifiy = QtModToWinMod(keyMod);
return RegisterHotKey(w_handle, hotkey_id, modifiy, VkKeyScan
(keyValue.toAscii()));
#else //liunx or mac os are not implement...
Q_UNUSED(window);
Q_UNUSED(keyValue);
Q_UNUSED(keyMod);
return false;
#endif
}
示例8: encodeUnicode
QString encodeUnicode(const QString & unicode)
{
QString encoded;
for (int i = 0; i < unicode.length(); ++i)
{
QChar ch = unicode[i];
if (ch == ch.toAscii())
{
encoded += ch;
}
else
{
encoded += "\\u" + QString("%1").arg((ushort) ch.unicode(), (int) 4, (int) 16, QChar('0')).toUpper();
}
}
return encoded;
}
示例9: mountNetwork
bool EPath::mountNetwork(QChar drive) {
// Mount network drive
QProcess net_use;
LAPP_ << "Mounting network path to " << drive.toAscii();
QString mount_command = QString("net use %1: \"%2\"").arg(drive).arg(m_path);
LDEBUG_ << "Executing: " << QSTR(mount_command);
net_use.start(mount_command);
net_use.waitForFinished();
if (net_use.exitCode() != 0)
return false;
m_remote_path_mounted = true;
m_usable_drive = drive;
return true;
}
示例10: loadSettings
void Settings::loadSettings(const QString & fileName)
{
QString path = fileName;
if(fileName.isEmpty())
{
path = iniPath();
}
if(!path.isEmpty())
{
QSettings ini(path, QSettings::IniFormat);
for(ParametersMap::const_iterator iter = defaultParameters_.begin(); iter!=defaultParameters_.end(); ++iter)
{
const QString & key = iter.key();
QVariant value = ini.value(key, QVariant());
if(value.isValid())
{
QString str = value.toString();
if(str.contains(";") && str.size() != getParameter(key).toString().size())
{
// If a string list is modified, update the value
// (assuming that index < 10... one character for index)
QChar index = str.at(0);
str = getParameter(key).toString();
str[0] = index.toAscii();
value = QVariant(str);
UINFO("Updated list of parameter \"%s\"", key.toStdString().c_str());
}
setParameter(key, value);
}
}
UINFO("Settings loaded from %s.", path.toStdString().c_str());
}
else
{
parameters_ = defaultParameters_;
UINFO("Settings set to defaults.");
}
if(cv::gpu::getCudaEnabledDeviceCount() == 0)
{
Settings::setFeature2D_SURF_gpu(false);
Settings::setFeature2D_Fast_gpu(false);
Settings::setFeature2D_ORB_gpu(false);
}
}
示例11: isVowell
bool isVowell(QChar v){
if ( v > 'A' || v < 'z')
return false;
v = v.toLower();
switch (v.toAscii())
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'y':
return true;
default:
break;
}
return false;
}
示例12: characters
bool XLIFFHandler::characters(const QString &ch)
{
if (currentContext() == XC_ph) {
// handle the content of <ph> elements
for (int i = 0; i < ch.count(); ++i) {
QChar chr = ch.at(i);
if (accum.endsWith(QLatin1Char('\\')))
accum[accum.size() - 1] = QLatin1Char(charFromEscape(chr.toAscii()));
else
accum.append(chr);
}
} else {
QString t = ch;
t.replace(QLatin1String("\r"), QLatin1String(""));
accum.append(t);
}
return true;
}
示例13: sanitize
QString TextUtils::sanitize(QString const& original)
{
QString result;
for (int i = 0; i < original.length(); i++)
{
QChar c = original.at(i);
uchar_t mychar = c.toAscii();
bool valid = sfn_chars[mychar/8] & ( 1 << (mychar % 8) );
if (valid) {
result.append(c);
} else {
result.append("_");
}
}
return result;
}
示例14: keyPressEvent
void Loader::keyPressEvent(QKeyEvent* e)
{
int key = e->key();
if(this->running == false)
return;
if(this->disableIO)
return;
if(e->matches((QKeySequence::Copy))) {
copy();
return;
}
if(e->matches((QKeySequence::Paste))) {
QClipboard *clip = QApplication::clipboard();
QString command = clip->text();
this->insertPlainText(command);
QByteArray barry(command.toAscii());
process->write(barry);
return;
}
switch(key)
{
case Qt::Key_Enter:
case Qt::Key_Return:
key = '\n';
break;
case Qt::Key_Backspace:
key = '\b';
break;
default:
if(key & Qt::Key_Escape)
return;
QChar c = e->text().at(0);
key = (int)c.toAscii();
break;
}
QByteArray barry;
barry.append((char)key);
process->write(barry);
}
示例15: computeFormula
QVariant Cell::computeFormula(const QString &formula, SpreadSheet *widget) const
{
QVariant result = QVariant::Invalid,
firstOperand = QVariant::Invalid,
secondOperand = QVariant::Invalid;
QString aux = formula;
int firstOp = firstOperatorPosition(aux);
if (firstOp == -1)
result = parseMember(aux, widget);
while (firstOp != -1)
{
if (result == QVariant::Invalid)
firstOperand = parseMember(aux.left(firstOp), widget);
else
firstOperand = result;
QChar firstOperator = aux[firstOp];
aux = aux.mid(firstOp+1);
firstOp = firstOperatorPosition(aux);
if (firstOp == -1)
secondOperand = parseMember(aux, widget);
else
secondOperand = parseMember(aux.left(firstOp), widget);
switch (firstOperator.toAscii())
{
case '+':
result = firstOperand.toDouble() + secondOperand.toDouble();
break;
case '-':
result = firstOperand.toDouble() - secondOperand.toDouble();
break;
case '*':
result = firstOperand.toDouble() * secondOperand.toDouble();
break;
case '/':
result = firstOperand.toDouble() / secondOperand.toDouble();
break;
}
}
return result;
}