当前位置: 首页>>代码示例>>C++>>正文


C++ QChar::isPrint方法代码示例

本文整理汇总了C++中QChar::isPrint方法的典型用法代码示例。如果您正苦于以下问题:C++ QChar::isPrint方法的具体用法?C++ QChar::isPrint怎么用?C++ QChar::isPrint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QChar的用法示例。


在下文中一共展示了QChar::isPrint方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: expressionChanged

void CalculatorDialog::expressionChanged(bool validExpression, bool validPointer, int_t value)
{
    if(!validExpression)
    {
        ui->txtBin->setText("");
        ui->txtSignedDec->setText("");
        ui->txtUnsignedDec->setText("");
        ui->txtHex->setText("");
        ui->txtOct->setText("");
        ui->txtAscii->setText("");
        ui->txtUnicode->setText("");
        ui->txtExpression->setStyleSheet("border: 2px solid red");
        emit validAddress(false);
    }
    else
    {
        ui->txtExpression->setStyleSheet("");
        ui->txtHex->setText(inFormat(value, N_HEX));
        ui->txtSignedDec->setText(inFormat(value, N_SDEC));
        ui->txtUnsignedDec->setText(inFormat(value, N_UDEC));
        int cursorpos = ui->txtBin->cursorPosition();
        ui->txtBin->setText(inFormat(value, N_BIN));
        ui->txtBin->setCursorPosition(cursorpos);
        ui->txtOct->setText(inFormat(value, N_OCT));
        if((value == (value & 0xFF)))
        {
            QChar c = QChar::fromLatin1((char)value);
            if(c.isPrint())
                ui->txtAscii->setText("'" + QString(c) + "'");
            else
                ui->txtAscii->setText("???");
        }
        else
            ui->txtAscii->setText("???");
        ui->txtAscii->setCursorPosition(1);
        if((value == (value & 0xFFF)))  //UNICODE?
        {
            QChar c = QChar::fromLatin1((wchar_t)value);
            if(c.isPrint())
                ui->txtUnicode->setText("L'" + QString(c) + "'");
            else
                ui->txtUnicode->setText("????");
        }
        else
        {
            ui->txtUnicode->setText("????");
        }
        ui->txtUnicode->setCursorPosition(2);
        emit validAddress(validPointer);
    }
}
开发者ID:nihilus,项目名称:x64dbg,代码行数:51,代码来源:CalculatorDialog.cpp

示例2: stripAccelerator

int AccelString::stripAccelerator(QString &text)
{
  // Note: this code is derived from QAccel::shortcutKey
  int p = 0;

  while (p >= 0)
  {
    p = text.indexOf('&', p)+1;

    if (p <= 0 || p >= (int)text.length())
      break;

    if (text[p] != '&')
    {
      QChar c = text[p];
      if (c.isPrint())
      {
        text.remove(p-1,1);
	return p-1;
      }
    }

    p++;
  }

  return -1;
}
开发者ID:CDrummond,项目名称:cantata,代码行数:27,代码来源:acceleratormanager.cpp

示例3: match

/*
    \internal
    Matches the current intermediate key sequence + the latest
    keyevent, with and AccelItem. Returns Identical,
    PartialMatch or NoMatch, and fills \a temp with the
    resulting key sequence.
*/
Qt::SequenceMatch QAccelManager::match( QKeyEvent *e, QAccelItem* item, QKeySequence& temp )
{
    SequenceMatch result = Qt::NoMatch;
    int index = intermediate.count();
    temp = intermediate;

    int modifier = translateModifiers( e->state() );

    if ( e->key() && e->key() != Key_unknown) {
	int key = e->key()  | modifier;
	if ( e->key() == Key_BackTab ) {
	    /*
	    In QApplication, we map shift+tab to shift+backtab.
	    This code here reverts the mapping in a way that keeps
	    backtab and shift+tab accelerators working, in that
	    order, meaning backtab has priority.*/
	    key &= ~SHIFT;

	    temp.setKey( key, index );
	    if ( Qt::NoMatch != (result = temp.matches( item->key )) )
		return result;
	    if ( e->state() & ShiftButton )
		key |= SHIFT;
	    key = Key_Tab | ( key & MODIFIER_MASK );
	    temp.setKey( key, index );
	    if ( Qt::NoMatch != (result = temp.matches( item->key )) )
		return result;
	} else {
	    temp.setKey( key, index );
	    if ( Qt::NoMatch != (result = temp.matches( item->key )) )
		return result;
	}

	if ( key == Key_BackTab ) {
	    if ( e->state() & ShiftButton )
		key |= SHIFT;
	    temp.setKey( key, index );
	    if ( Qt::NoMatch != (result = temp.matches( item->key )) )
		return result;
	}
    }
    if ( !e->text().isEmpty() ) {
        QChar c = e->text()[0];
        // be in accordance with accoQAccel::shortcutKey()
        if ( modifier != 0 && c.isPrint() )
            c = c.upper();
	temp.setKey( (int)c.unicode() | UNICODE_ACCEL | modifier, index );
	result = temp.matches( item->key );
    }
    return result;
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:58,代码来源:qaccel.cpp

示例4: func_clean

// Function: CLEAN
Value func_clean(valVector args, ValueCalc *calc, FuncExtra *)
{
    QString str(calc->conv()->asString(args[0]).asString());
    QString result;
    QChar   c;
    int     i;
    int     l = str.length();

    for (i = 0; i < l; ++i) {
        c = str[i];
        if (c.isPrint())
            result += c;
    }

    return Value(result);
}
开发者ID:crayonink,项目名称:calligra-2,代码行数:17,代码来源:text.cpp

示例5: valueString

QString CharDataInformation::valueString(quint8 value)
{
    QChar qchar = QChar::fromLatin1(value);
    qchar = qchar.isPrint() ? qchar : QChar(QChar::ReplacementCharacter);
    QString charStr = QLatin1Char('\'') + qchar + QLatin1Char('\'');
    if (Kasten2::StructViewPreferences::showCharNumericalValue())
    {
        int base = displayBase();
        QString num = QString::number(value, base);
        if (base == 16)
            num.prepend(QLatin1String("0x"));
        if (base == 10 && Kasten2::StructViewPreferences::localeAwareDecimalFormatting())
            num = KGlobal::locale()->formatNumber(num, false, 0);
        charStr += QLatin1String(" (") + num + QLatin1Char(')');
    }
    return charStr;
}
开发者ID:ShermanHuang,项目名称:kdesdk,代码行数:17,代码来源:chardatainformation.cpp

示例6: shortcutKey

int QAccel::shortcutKey( const QString &str )
{
    int p = 0;
    while ( p >= 0 ) {
        p = str.find( '&', p ) + 1;
        if ( p <= 0 || p >= (int)str.length() )
            return 0;
        if ( str[p] != '&' ) {
            QChar c = str[p];
            if ( c.isPrint() ) {
                c = c.upper();
                return c.unicode() + ALT + UNICODE_ACCEL;
            }
        }
        p++;
    }
    return 0;
}
开发者ID:kthxbyte,项目名称:QT2-Linaro,代码行数:18,代码来源:qaccel.cpp

示例7: convertKey

/**
 * Convert Qt key input into Neovim key-notation
 *
 * see QKeyEvent
 */
QString InputConv::convertKey(const QString& text, int k, Qt::KeyboardModifiers mod)
{
	if (specialKeys.contains(k)) {
		return QString("<%1%2>").arg(modPrefix(mod)).arg(specialKeys.value(k));
	} else if (text.isEmpty()) {
		// This is a special key we can't handle
		return QString();
	}

	// Escape < and backslash
	if (text == "<") {
		return QString("<%1%2>").arg(modPrefix(mod)).arg("lt");
	}
	if (text == "\\") {
		return QString("<%1%2>").arg(modPrefix(mod)).arg("Bslash");
	}

	QChar c = text.at(0);
	// Remove SHIFT
	if (c.unicode() < 0x100 && !c.isLetterOrNumber() && c.isPrint()) {
		mod &= ~Qt::ShiftModifier;
	}

	// Remove CTRL empty characters at the start of the ASCII range
	if (c.unicode() < 0x20) {
		mod &= ~Qt::ControlModifier;
	}

	// Format with prefix if necessary
	QString prefix = modPrefix(mod);
	if (!prefix.isEmpty()) {
		return QString("<%1%2>").arg(prefix).arg(text);
	}

	return text;
}
开发者ID:foliage11111,项目名称:neovim-qt,代码行数:41,代码来源:input.cpp

示例8: convertKey

/**
 * Convert Qt key input into Neovim key-notation
 *
 * see QKeyEvent
 */
QString InputConv::convertKey(const QString& text, int k, Qt::KeyboardModifiers mod)
{
    if ( mod & Qt::KeypadModifier ) {
		switch (k) {
		case Qt::Key_Home:
			return QString("<%1kHome>").arg(modPrefix(mod));
		case Qt::Key_End:
			return QString("<%1kEnd>").arg(modPrefix(mod));
		case Qt::Key_PageUp:
			return QString("<%1kPageUp>").arg(modPrefix(mod));
		case Qt::Key_PageDown:
			return QString("<%1kPageDown>").arg(modPrefix(mod));
		case Qt::Key_Plus:
			return QString("<%1kPlus>").arg(modPrefix(mod));
		case Qt::Key_Minus:
			return QString("<%1kMinus>").arg(modPrefix(mod));
		case Qt::Key_multiply:
			return QString("<%1kMultiply>").arg(modPrefix(mod));
		case Qt::Key_division:
			return QString("<%1kDivide>").arg(modPrefix(mod));
		case Qt::Key_Enter:
			return QString("<%1kEnter>").arg(modPrefix(mod));
		case Qt::Key_Period:
			return QString("<%1kPoint>").arg(modPrefix(mod));
		case Qt::Key_0:
			return QString("<%1k0>").arg(modPrefix(mod));
		case Qt::Key_1:
			return QString("<%1k1>").arg(modPrefix(mod));
		case Qt::Key_2:
			return QString("<%1k2>").arg(modPrefix(mod));
		case Qt::Key_3:
			return QString("<%1k3>").arg(modPrefix(mod));
		case Qt::Key_4:
			return QString("<%1k4>").arg(modPrefix(mod));
		case Qt::Key_5:
			return QString("<%1k5>").arg(modPrefix(mod));
		case Qt::Key_6:
			return QString("<%1k6>").arg(modPrefix(mod));
		case Qt::Key_7:
			return QString("<%1k7>").arg(modPrefix(mod));
		case Qt::Key_8:
			return QString("<%1k8>").arg(modPrefix(mod));
		case Qt::Key_9:
			return QString("<%1k9>").arg(modPrefix(mod));
		}
    }

	if (specialKeys.contains(k)) {
		return QString("<%1%2>").arg(modPrefix(mod)).arg(specialKeys.value(k));
	}

	QChar c;
	// Escape < and backslash
	if (text == "<") {
		return QString("<%1%2>").arg(modPrefix(mod)).arg("lt");
	} else if (text == "\\") {
		return QString("<%1%2>").arg(modPrefix(mod)).arg("Bslash");
	} else if (text.isEmpty()) {
		// on macs, text is empty for ctrl+key and cmd+key combos (with or without alt)
		if (mod & ControlModifier || mod & CmdModifier) {
			// ignore ctrl, alt and cmd key combos by themselves
			QList<Qt::Key> keys = { Key_Control, Key_Alt, Key_Cmd };
			if (keys.contains((Qt::Key)k)) {
				return QString();
			} else if (mod & ShiftModifier) {
				// Ignore event for Ctrl-Shift
				// Fixes issue #344, C-S- being treated as C-Space
				return QString();
			} else {
				// key code will be the value of the char (hopefully)
				c = QChar(k);
			}
		} else {
			// This is a special key we can't handle
			return QString();
		}
	} else {
		// Key event compression is disabled, text has one char
		c = text.at(0);
	}

	// Remove SHIFT
	if (c.unicode() >= 0x80 || (!c.isLetterOrNumber() && c.isPrint())) {
		mod &= ~ShiftModifier;
	}

	// Remove CTRL empty characters at the start of the ASCII range
	if (c.unicode() < 0x20) {
		mod &= ~ControlModifier;
	}

	// Format with prefix if necessary
	QString prefix = modPrefix(mod);
	if (!prefix.isEmpty()) {
		return QString("<%1%2>").arg(prefix).arg(c);
//.........这里部分代码省略.........
开发者ID:equalsraf,项目名称:neovim-qt,代码行数:101,代码来源:input.cpp

示例9: eventFilter

bool ShortcutEdit::eventFilter(QObject* watched, QEvent* event)
{
    if ((watched == m_edit) && (event->type() == QEvent::KeyPress)) {
        QKeyEvent* key_event = static_cast<QKeyEvent*>(event);

        Qt::KeyboardModifiers modifiers = key_event->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier);
        int key = key_event->key();

        switch (key) {
        // Don't do anything if they only press a modifier
        case Qt::Key_Shift:
        case Qt::Key_Control:
        case Qt::Key_Meta:
        case Qt::Key_Alt:
            return true;

        // Clear on backspace unless modifier is used
        case Qt::Key_Backspace:
        case Qt::Key_Delete:
            if (modifiers == Qt::NoModifier) {
                clear();
                return true;
            }
            break;

        // Allow tab to change focus
        case Qt::Key_Tab:
        case Qt::Key_Backtab:
            return false;

        default:
            break;
        }

        // Add modifiers; only allow shift if it is not required for key of shortcut
        if ((modifiers & Qt::ShiftModifier) && !key_event->text().isEmpty()) {
            QChar c = key_event->text().at(0);
            if (c.isPrint() && !c.isLetterOrNumber() && !c.isSpace()) {
                key |= Qt::SHIFT;
            }
        }
        if (modifiers & Qt::ControlModifier) {
            key |= Qt::CTRL;
        }
        if (modifiers & Qt::MetaModifier) {
            key |= Qt::META;
        }
        if (modifiers & Qt::AltModifier) {
            key |= Qt::ALT;
        }

        // Change shortcut
        m_shortcut = QKeySequence(key);
        setText();
        emit changed();

        return true;
    } else {
        return QWidget::eventFilter(watched, event);
    }
}
开发者ID:JackH79,项目名称:focuswriter,代码行数:61,代码来源:shortcut_edit.cpp

示例10: keyPressEvent

void MainWidget::keyPressEvent(QKeyEvent *event) {
    QChar c = event->text()[0];
    if (c.isPrint()) {
        undo->push(new Text_Command(this, lastx, lasty, c));
        if (++lastx >= xasc) {
            lastx = 0;
            if (++lasty >= yasc) {
                lasty = 0;
            }
        }
        update(pixelRect(lastx, lasty));
        emit somethingChanged(true);
    } else if (event->key() == Qt::Key_Delete) {
        undo->push(new Text_Command(this, lastx, lasty, QChar()));
        emit somethingChanged(true);
    } else if (event->key() == Qt::Key_Backspace) {
        int oldx = lastx;
        int oldy = lasty;
        if (--lastx < 0) {
            lastx = xasc-1;
            if (--lasty < 0) {
                lasty = yasc-1;
            }
        }
        undo->push(new Text_Command(this, lastx, lasty, QChar()));
        update(pixelRect(oldx, oldy));
        emit somethingChanged(true);
    } else if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
        int oldx = lastx;
        int oldy = lasty;
        lastx = 0;
        if (++lasty >= yasc) {
            lasty = 0;
        }
        update(pixelRect(oldx, oldy).united(pixelRect(lastx, lasty)));
    } else if (event->key() == Qt::Key_Up) {
        int oldy = lasty;
        if (--lasty < 0) {
            lasty = oldy;
        }
        update(pixelRect(lastx, oldy).united(pixelRect(lastx, lasty)));
    } else if (event->key() == Qt::Key_Down) {
        int oldy = lasty;
        if (++lasty >= yasc) {
            lasty = oldy;
        }
        update(pixelRect(lastx, oldy).united(pixelRect(lastx, lasty)));
    } else if (event->key() == Qt::Key_Left) {
        int oldx = lastx;
        if (--lastx < 0) {
            lastx = oldx;
        }
        update(pixelRect(oldx, lasty).united(pixelRect(lastx, lasty)));
    } else if (event->key() == Qt::Key_Right) {
        int oldx = lastx;
        if (++lastx >= xasc) {
            lastx = oldx;
        }
        update(pixelRect(oldx, lasty).united(pixelRect(lastx, lasty)));
    } else {
        QWidget::keyPressEvent(event);
    }
}
开发者ID:cloudkitsch,项目名称:IRC-Paint,代码行数:63,代码来源:MainWidget.cpp


注:本文中的QChar::isPrint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。