本文整理汇总了C++中qstr函数的典型用法代码示例。如果您正苦于以下问题:C++ qstr函数的具体用法?C++ qstr怎么用?C++ qstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qstr
void MonoIcon::ensureLoaded() const {
if (_size.isValid()) {
return;
}
const uchar *data = _mask->data();
int size = _mask->size();
auto generateTag = qstr("GENERATE:");
if (size > generateTag.size() && !memcmp(data, generateTag.data(), generateTag.size())) {
size -= generateTag.size();
data += generateTag.size();
auto sizeTag = qstr("SIZE:");
if (size > sizeTag.size() && !memcmp(data, sizeTag.data(), sizeTag.size())) {
size -= sizeTag.size();
data += sizeTag.size();
QByteArray baForStream(reinterpret_cast<const char*>(data), size);
QBuffer buffer(&baForStream);
buffer.open(QIODevice::ReadOnly);
QDataStream stream(&buffer);
stream.setVersion(QDataStream::Qt_5_1);
qint32 width = 0, height = 0;
stream >> width >> height;
t_assert(stream.status() == QDataStream::Ok);
switch (cScale()) {
case dbisOne: _size = QSize(width, height); break;
case dbisOneAndQuarter: _size = QSize(pxAdjust(width, 5), pxAdjust(height, 5)); break;
case dbisOneAndHalf: _size = QSize(pxAdjust(width, 6), pxAdjust(height, 6)); break;
case dbisTwo: _size = QSize(width * 2, height * 2); break;
}
} else {
示例2: QTableWidgetItem
//This is intended to write the information of save data to QTableView.
void save_data_info_dialog::UpdateData()
{
m_list->clearContents();
int num_entries = 4; // set this to number of members in struct
m_list->setRowCount(num_entries);
//Maybe there should be more details of save data.
m_list->setItem(0, 0, new QTableWidgetItem(tr("User ID")));
m_list->setItem(0, 1, new QTableWidgetItem("00000001 (Default)"));
m_list->setItem(1, 0, new QTableWidgetItem(tr("Title")));
m_list->setItem(1, 1, new QTableWidgetItem(qstr(m_entry.title)));
m_list->setItem(2, 0, new QTableWidgetItem(tr("Subtitle")));
m_list->setItem(2, 1, new QTableWidgetItem(qstr(m_entry.subtitle)));
m_list->setItem(3, 0, new QTableWidgetItem(tr("Detail")));
m_list->setItem(3, 1, new QTableWidgetItem(qstr(m_entry.details)));
QImage img;
if (m_entry.iconBuf.size() > 0 && img.loadFromData((uchar*)&m_entry.iconBuf[0], m_entry.iconBuf.size(), "PNG"))
{
m_list->insertRow(0);
QTableWidgetItem* img_item = new QTableWidgetItem();
img_item->setData(Qt::DecorationRole, QPixmap::fromImage(img));
m_list->setItem(0, 0, new QTableWidgetItem(tr("Icon")));
m_list->setItem(0, 1, img_item);
}
}
示例3: err
bool UsernameBox::onUpdateFail(const RPCError &error) {
if (MTP::isDefaultHandledError(error)) return false;
_saveRequestId = 0;
QString err(error.type());
if (err == qstr("USERNAME_NOT_MODIFIED") || _sentUsername == App::self()->username) {
App::self()->setName(TextUtilities::SingleLine(App::self()->firstName), TextUtilities::SingleLine(App::self()->lastName), TextUtilities::SingleLine(App::self()->nameOrPhone), TextUtilities::SingleLine(_sentUsername));
closeBox();
return true;
} else if (err == qstr("USERNAME_INVALID")) {
_username->setFocus();
_username->showError();
_errorText = lang(lng_username_invalid);
update();
return true;
} else if (err == qstr("USERNAME_OCCUPIED") || err == qstr("USERNAMES_UNAVAILABLE")) {
_username->setFocus();
_username->showError();
_errorText = lang(lng_username_occupied);
update();
return true;
}
_username->setFocus();
return true;
}
示例4: filedialogInit
void filedialogInit() {
if (cDialogLastPath().isEmpty()) {
#ifdef Q_OS_WIN
// hack to restore previous dir without hurting performance
QSettings settings(QSettings::UserScope, qstr("QtProject"));
settings.beginGroup(qstr("Qt"));
QByteArray sd = settings.value(qstr("filedialog")).toByteArray();
QDataStream stream(&sd, QIODevice::ReadOnly);
if (!stream.atEnd()) {
int version = 3, _QFileDialogMagic = 190;
QByteArray splitterState;
QByteArray headerData;
QList<QUrl> bookmarks;
QStringList history;
QString currentDirectory;
qint32 marker;
qint32 v;
qint32 viewMode;
stream >> marker;
stream >> v;
if (marker == _QFileDialogMagic && v == version) {
stream >> splitterState
>> bookmarks
>> history
>> currentDirectory
>> headerData
>> viewMode;
cSetDialogLastPath(currentDirectory);
}
示例5: stopCheck
bool PhoneWidget::phoneSubmitFail(const RPCError &error) {
if (MTP::isFloodError(error)) {
stopCheck();
_sentRequest = 0;
showPhoneError(langFactory(lng_flood_error));
return true;
}
if (MTP::isDefaultHandledError(error)) return false;
stopCheck();
_sentRequest = 0;
auto &err = error.type();
if (err == qstr("PHONE_NUMBER_FLOOD")) {
Ui::show(Box<InformBox>(lang(lng_error_phone_flood)));
return true;
} else if (err == qstr("PHONE_NUMBER_INVALID")) { // show error
showPhoneError(langFactory(lng_bad_phone));
return true;
}
if (cDebug()) { // internal server error
auto text = err + ": " + error.description();
showPhoneError([text] { return text; });
} else {
showPhoneError(langFactory(lng_server_error));
}
return false;
}
示例6: stopCheck
bool IntroPwdCheck::pwdSubmitFail(const RPCError &error) {
if (MTP::isFloodError(error)) {
sentRequest = 0;
stopCheck();
_codeField.setDisabled(false);
showError(lang(lng_flood_error));
_pwdField.setDisabled(false);
_pwdField.notaBene();
return true;
}
if (MTP::isDefaultHandledError(error)) return false;
sentRequest = 0;
stopCheck();
_pwdField.setDisabled(false);
_codeField.setDisabled(false);
const QString &err = error.type();
if (err == qstr("PASSWORD_HASH_INVALID")) {
showError(lang(lng_signin_bad_password));
_pwdField.selectAll();
_pwdField.notaBene();
return true;
} else if (err == qstr("PASSWORD_EMPTY")) {
intro()->onBack();
}
if (cDebug()) { // internal server error
showError(err + ": " + error.description());
} else {
showError(lang(lng_server_error));
}
_pwdField.setFocus();
return false;
}
示例7: ProgressBarSetMsg
void msg_dialog_frame::ProgressBarSetMsg(u32 index, const std::string& msg)
{
if (m_dialog)
{
if (index == 0 && m_text1) m_text1->setText(qstr(msg));
if (index == 1 && m_text2) m_text2->setText(qstr(msg));
}
}
示例8: qstr
/**
* Returns false if the game should be hidden because it doesn't match search term in toolbar.
*/
bool game_list_frame::SearchMatchesApp(const std::string& name, const std::string& serial)
{
if (m_Search_Bar->text() != "")
{
QString searchText = m_Search_Bar->text().toLower();
return qstr(name).toLower().contains(searchText) || qstr(serial).toLower().contains(searchText);
}
return true;
}
示例9: qstr
void memory_viewer_panel::ShowMemory()
{
QString t_mem_addr_str;
QString t_mem_hex_str;
QString t_mem_ascii_str;
for(u32 addr = m_addr; addr != m_addr + m_rowcount * m_colcount; addr += m_colcount)
{
t_mem_addr_str += qstr(fmt::format("%08x", addr));
if (addr != m_addr + m_rowcount * m_colcount - m_colcount) t_mem_addr_str += "\r\n";
}
for (u32 row = 0; row < m_rowcount; row++)
{
for (u32 col = 0; col < m_colcount; col++)
{
u32 addr = m_addr + row * m_colcount + col;
if (vm::check_addr(addr))
{
const u8 rmem = vm::read8(addr);
t_mem_hex_str += qstr(fmt::format("%02x ", rmem));
const bool isPrintable = rmem >= 32 && rmem <= 126;
t_mem_ascii_str += qstr(isPrintable ? std::string(1, rmem) : ".");
}
else
{
t_mem_hex_str += "??";
t_mem_ascii_str += "?";
if (col != m_colcount - 1) t_mem_hex_str += " ";
}
}
if (row != m_rowcount - 1)
{
t_mem_hex_str += "\r\n";
t_mem_ascii_str += "\r\n";
}
}
t_mem_addr->setText(t_mem_addr_str);
t_mem_hex->setText(t_mem_hex_str);
t_mem_ascii->setText(t_mem_ascii_str);
// Adjust Text Boxes
textSize = fontMetrics->size(0, t_mem_addr->text());
t_mem_addr->setFixedSize(textSize.width() + 10, textSize.height() + 10);
textSize = fontMetrics->size(0, t_mem_hex->text());
t_mem_hex->setFixedSize(textSize.width() + 10, textSize.height() + 10);
textSize = fontMetrics->size(0, t_mem_ascii->text());
t_mem_ascii->setFixedSize(textSize.width() + 10, textSize.height() + 10);
}
示例10: telegramFaqLink
QString telegramFaqLink() {
QString result = qsl("https://telegram.org/faq");
if (cLang() > languageDefault && cLang() < languageCount) {
const char *code = LanguageCodes[cLang()].c_str();
if (qstr("de") == code || qstr("es") == code || qstr("it") == code || qstr("ko") == code) {
result += qsl("/") + code;
} else if (qstr("pt_BR") == code) {
result += qsl("/br");
}
}
return result;
}
示例11: disasm
void cg_disasm_window::ShowDisasm()
{
if (QFileInfo(m_path_last).isFile())
{
CgBinaryDisasm disasm(sstr(m_path_last));
disasm.BuildShaderBody();
m_disasm_text->setText(qstr(disasm.GetArbShader()));
m_glsl_text->setText(qstr(disasm.GetGlslShader()));
}
else if (!m_path_last.isEmpty())
{
LOG_ERROR(LOADER, "CgDisasm: Failed to open %s", sstr(m_path_last));
}
}
示例12: f
bool DcOptions::loadFromFile(const QString &path) {
QVector<MTPDcOption> options;
QFile f(path);
if (!f.open(QIODevice::ReadOnly)) {
LOG(("MTP Error: could not read '%1'").arg(path));
return false;
}
QTextStream stream(&f);
stream.setCodec("UTF-8");
while (!stream.atEnd()) {
auto line = stream.readLine();
auto components = line.split(QRegularExpression(R"(\s)"), QString::SkipEmptyParts);
if (components.isEmpty() || components[0].startsWith('#')) {
continue;
}
auto error = [line] {
LOG(("MTP Error: in .tdesktop-endpoints expected 'dcId host port [tcpo_only] [media_only]', got '%1'").arg(line));
return false;
};
if (components.size() < 3) {
return error();
}
auto dcId = components[0].toInt();
auto ip = components[1];
auto port = components[2].toInt();
auto host = QHostAddress();
if (dcId <= 0 || dcId >= internal::kDcShift || !host.setAddress(ip) || port <= 0) {
return error();
}
auto flags = MTPDdcOption::Flags(0);
if (host.protocol() == QAbstractSocket::IPv6Protocol) {
flags |= MTPDdcOption::Flag::f_ipv6;
}
for (auto &option : components.mid(3)) {
if (option.startsWith('#')) {
break;
} else if (option == qstr("tcpo_only")) {
flags |= MTPDdcOption::Flag::f_tcpo_only;
} else if (option == qstr("media_only")) {
flags |= MTPDdcOption::Flag::f_media_only;
} else {
return error();
}
}
options.push_back(MTP_dcOption(MTP_flags(flags), MTP_int(dcId), MTP_string(ip), MTP_int(port)));
}
示例13: qstr
bool MultiPropertySelector_accessor::set_value( const std::string& str ) {
QString qstr( str.c_str() );
// str is just an element of an xml file, hence can not be parsed
// by QDomDocument. We need to add a root element.
qstr = "<root>" + qstr + "</root>";
QDomDocument doc;
bool parsed = doc.setContent( qstr );
appli_assert( parsed );
QDomElement root_element = doc.documentElement();
QDomElement elem = root_element.firstChild().toElement();
QString count_str = elem.attribute( "count" );
int count = count_str.toInt();
QString prop_string = elem.attribute( "value" );
QStringList prop_list = QStringList::split( ";", prop_string );
for( int i = 0 ; i < prop_list.size() ; i++ ) {
QString name = prop_list[i];
int id = 0;
for( ; id < selector_->count() ; id++ ) {
if( selector_->text( id ) == name ) {
selector_->setCurrentItem( id );
break;
}
}
}
return true;
}
示例14: qstr
void ChessWidget::onPutFEN() const
{
char fen[Board::FENsize];
cpos_.toFEN(fen);
QString qstr(fen);
QApplication::clipboard()->setText(qstr);
}
示例15: QWidget
Csv_input_mgrid_dialog::Csv_input_mgrid_dialog(std::ifstream& infile, QWidget* parent,
const char* name )
: QWidget( parent )
{
setupUi(this);
std::streampos mark = infile.tellg();
std::string str;
std::getline(infile, str);
QString qstr(str.c_str());
QStringList property_names = qstr.split(",");
X_col_name_->addItems(property_names);
X_col_name_->addItem("None");
Y_col_name_->addItems(property_names);
Y_col_name_->addItem("None");
Z_col_name_->addItems(property_names);
Z_col_name_->addItem("None");
//Set default selection
X_col_name_->setCurrentIndex(0);
Y_col_name_->setCurrentIndex(std::min(1,property_names.size()));
Z_col_name_->setCurrentIndex(std::min(2,property_names.size()));
mask_col_name_->addItems(property_names);
name_->setFocus();
}