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


C++ QTextCodec类代码示例

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


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

示例1: CheckError

bool Pack::CheckError(QProcess &pprocess)
{
	QTextCodec *gbk = QTextCodec::codecForName("GBK");
	QString error = gbk->toUnicode(pprocess.readAllStandardError());
	if (error.toLower().contains("error:") 
		|| error.toLower().contains("exception:")
		|| error.toLower().contains(" error")
		|| error.toLower().contains(" exception")
		|| error.toLower().contains("build failed")){
		QString standardOut = gbk->toUnicode(pprocess.readAllStandardOutput());
		emit GenerateError(error.append(standardOut));
		return false;
	}
	return true;
}
开发者ID:cnandroidlib,项目名称:AutopackingAndroid,代码行数:15,代码来源:Pack.cpp

示例2: updateBuddyListView

void EvaQunMemberPicker::updateBuddyListView()
{
	//if(!mQun) return;
	lvBuddyList->clear();
	
	QTextCodec *codec = QTextCodec::codecForName("GB18030");
	std::list<std::string> names = EvaMain::user->getGroupNames();
	std::list<std::string>::iterator groupIter;
	int i=0;
	for(groupIter = names.begin(); groupIter!= names.end(); ++groupIter){
		QString g = codec->toUnicode(groupIter->c_str());
		QCheckListItem *item = new QCheckListItem(lvBuddyList, g, QCheckListItem::CheckBox);
		item->setState(QCheckListItem::Off);
		groups[i++] = item;
	}
	
	//QunInfo info = mQun->getDetails();
	
	std::map<unsigned int, QQFriend>::iterator iter;
	std::map<unsigned int, QQFriend> list = (EvaMain::user->getFriendList()).getAllFriendsMap();
	for(iter = list.begin(); iter != list.end(); ++iter){
	
		int id = iter->second.getQQ();
		QString nick = EvaTextFilter::filter(codec->toUnicode(iter->second.getNick().c_str()));
		
		int groupIndex = iter->second.getGroupIndex();
		QCheckListItem *group = groups[groupIndex];
		if(!group) continue;
		
		short faceID = (iter->second.getFace())/3 + 1;
		if(faceID<1) faceID = 1;
		QCheckListItem *item = new QCheckListItem(group, nick + "(" + QString::number(id) + ")", QCheckListItem::CheckBox);

		QPixmap *pic = EvaMain::images->getFace(faceID, true);
		if(pic) {
			QImage img(pic->convertToImage().smoothScale(16, 16));
			item->setPixmap(0, QPixmap(img));
		}else{
			fprintf(stderr, "EvaQunMemberPicker::updateBuddyListView (id:%d, faceID:%d, %s) --  NULL QPixmap pointer, ignored!\n", id, faceID, nick.ascii());
		}
		if(mQun && mQun->hasMember(id))
			item->setState(QCheckListItem::On);
		else
			item->setState(QCheckListItem::Off);
			
		buddyList[id] = item;
	}
}
开发者ID:evareborn,项目名称:eva-nirvana,代码行数:48,代码来源:evaqunmemberpicker.cpp

示例3: find_winamp

bool KviWinampInterface::playMrl(const QString & mrl)
{
	HWND hWinamp = find_winamp(this);
	if(hWinamp)
	{
		QTextCodec * c = mediaplayer_get_codec();
		KviCString szMrl = c ? c->fromUnicode(mrl) : mrl.toUtf8();
		COPYDATASTRUCT cds;
		cds.dwData = IPC_PLAYFILE;
		cds.lpData = (void *)szMrl.ptr();
		cds.cbData = szMrl.len() + 1; // include space for null char
		SendMessage(hWinamp, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
		return true;
	}
	return false;
}
开发者ID:Dessa,项目名称:KVIrc,代码行数:16,代码来源:MpWinampInterface.cpp

示例4: on_openlib_clicked

void  ExcLoadDlg::on_openlib_clicked()
{
    if( m_libpath.isEmpty() ) {
        m_libpath   = m_curpath;
    }

    QTextCodec *codec = QTextCodec::codecForLocale();

    QString name = QFileDialog::getExistingDirectory(
                       this, codec->toUnicode("打开异常对应的elf文件和库路径"), m_libpath );
    if(!name.isEmpty()) {
        m_curpath   = name;
        m_libpath   = name;
        m_ui.LibPath->setText(name);
    }
}
开发者ID:wsue,项目名称:excanalyse,代码行数:16,代码来源:excloaddlg.cpp

示例5: uchardet_new

QString TagSetData::decode(const Tag &tag) const
{
    if (tag.encoded)
        return QTextCodec::codecForName(ENC_CODEC)->toUnicode(tag.value);

    if (!mTextCodec)
    {
        // Auto detect codepage ...........................
        uchardet_t uc = uchardet_new();

        for(int i=0; i<mTrackCount; ++i)
        {
            const QByteArray &performer = mTags.value(key(i, TAG_PERFORMER)).value;
            const QByteArray &title = mTags.value(key(i, TAG_TITLE)).value;

            uchardet_handle_data(uc, performer.data(), performer.length());
            uchardet_handle_data(uc, title.data(),     title.length());
        }

        uchardet_data_end(uc);
        mTextCodec = QTextCodec::codecForName(uchardet_get_charset(uc));
        if (!mTextCodec)
            mTextCodec = QTextCodec::codecForName("UTF-8");

        uchardet_delete(uc);
    }

    return mTextCodec->toUnicode(tag.value);
}
开发者ID:c-jheengut,项目名称:flacon,代码行数:29,代码来源:tagset.cpp

示例6: readWithEncoding

bool Serializer::readWithEncoding(const QString& filename, const QString& encoding, 
								  QString &txt)
{
	QByteArray file;
	QTextCodec *codec;
	if (encoding.isEmpty())
		codec = QTextCodec::codecForLocale();
	else
		codec = QTextCodec::codecForName(encoding.toLocal8Bit());
	if (loadRawText(filename, file))
	{
		txt = codec->toUnicode( file.data() );
		return true;
	}
	return false;
}
开发者ID:moceap,项目名称:scribus,代码行数:16,代码来源:serializer.cpp

示例7: doc

doctorChangeDialog::doctorChangeDialog( QWidget *parent, doctor* doc )
    : doc(doc), QDialog(parent)
{
    ui.setupUi(this);

    QByteArray fio(doc->fio), dolgnost(doc->dolgnost), work(doc->priem);
    //QTextCodec *codec = QTextCodec::codecForName("Windows-1251");
    QTextCodec *codec = QTextCodec::codecForName("CP866");
    QString fioString = codec->toUnicode(fio);
    QString dolgnostString = codec->toUnicode(dolgnost);
    QString workString = codec->toUnicode(work);
    ui.fio->setText( fioString );
    ui.cabinet->setText( QString::number( doc->cabinet ) );
    ui.speciality->setText( dolgnostString );
    ui.workHours->setText( workString );
}
开发者ID:artem-bochkarev,项目名称:alexandras_task,代码行数:16,代码来源:doctorChangeDialog.cpp

示例8: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    MainWindow w;
    if (argc > 1) {
        QTextCodec* textCodec = QTextCodec::codecForLocale();
        if (textCodec) {
            w.openFile(textCodec->toUnicode(argv[1]));
        }
    }

    w.show();

    return a.exec();
}
开发者ID:jungilhan,项目名称:monkeylogviewer,代码行数:16,代码来源:main.cpp

示例9: file

void ReportView::load()
{
	QFile file(reportFileName);
	if(!file.open(QFile::ReadOnly | QFile::Text))
		qDebug() << "not file open " << file.errorString() << endl;
	else
	{
		QByteArray data = file.readAll();
		QTextCodec *codec = Qt::codecForHtml(data);
		QString str = codec->toUnicode(data);
		if (Qt::mightBeRichText(str))
		{
			ui->textEdit->setHtml(str);
		}
	}
}
开发者ID:Horsmir,项目名称:hstest,代码行数:16,代码来源:reportview.cpp

示例10: actionCharacterEncoding

void MainWindow::actionCharacterEncoding(QAction *action)
{
	QString encoding;

	if (action && action->data().toInt() > 0)
	{
		QTextCodec *codec = QTextCodec::codecForMib(action->data().toInt());

		if (codec)
		{
			encoding = codec->name();
		}
	}

	m_windowsManager->setDefaultCharacterEncoding(encoding.toLower());
}
开发者ID:mboevink,项目名称:otter,代码行数:16,代码来源:MainWindow.cpp

示例11: getAmipString

QString getAmipString(const char * var)
{
	QString szRet;
	QString szString = eval_str(var);
	QTextCodec * pCodec = mediaplayer_get_codec();
	if(pCodec) {
#if (QT_VERSION < 0x050000)
		szRet = pCodec->toUnicode(szString.toLatin1());
#else
		szRet = pCodec->toUnicode(szString.toUtf8());
#endif
	} else {
		szRet = szString;
	}
	return szRet;
}
开发者ID:philouvb,项目名称:KVIrc,代码行数:16,代码来源:MpAmipInterface.cpp

示例12: out

//************************************************************************************************
void tGuiError::ExeCommand(QDataStream& _in)
{
    int num_error=-9999;
    QString error="";
    QString detail="";
    QString client_detail="";

    _in >> num_error;
    _in >> error;
    _in >> detail;
    _in >> client_detail;

    //Отмена транзакции из-за ошибки
    QByteArray block;
    QDataStream out(&block, QIODevice::WriteOnly);

    block.clear();

    QString command="CancelTransaction";

    out << command;
    emit SendCommand(block);

/*
         QTextCodec *codec =QTextCodec::codecForName("Windows-1251");
//        QTextCodec *codec =QTextCodec::codecForName("UTF-8");
        QTextCodec::setCodecForTr(codec);
        QTextCodec::setCodecForCStrings(codec);

    QString before="\\";
    QString after="/";
    QString ret=codec->toUnicode(_path.replace(before, after).toAscii());
    */

   QTextCodec *codec =QTextCodec::codecForName("Windows-1251");

   QTextCodec::setCodecForTr(codec);
   QTextCodec::setCodecForCStrings(codec);

    QMessageBox MB;
    QString S=QString::fromUtf8("Ошибка в команде ")+QString::number(num_error)+"\n"+client_detail;
    QString S1=codec->toUnicode(S.toAscii())+"\n"+detail;
    MB.setText(S1);
    MB.setWindowTitle(error);
    MB.exec();

}
开发者ID:Balog,项目名称:Synchonization,代码行数:48,代码来源:tClientGuiCommand.cpp

示例13: property

bool pEditor::saveFile( const QString& s )
{
    if ( !isModified() )
        return true;

    // get filename
    QString fn = s;
    if ( s.isEmpty() )
        fn = property( "fileName" ).toString();
    // get path
    QString fp = QFileInfo( fn ).path();

    // filename
    QFile f( fn );
    // filename dir
    QDir d;
    // create bak folder
    if ( !d.exists( fp ) )
        if ( !d.mkpath( fp ) )
            return false;

    // set correct path
    d.setPath( fp );
    // try open file to write in
    if ( !f.open( QFile::WriteOnly ) )
    {
        MonkeyCore::messageManager()->appendMessage( tr( "Cannot write file %1:\n%2." ).arg( fn ).arg( f.errorString() ) );
        return false;
    }

    // writing file
    QApplication::setOverrideCursor( Qt::WaitCursor );
    
    f.resize( 0 );
    QTextCodec* c = QTextCodec::codecForName( property( "codec" ).toString().toUtf8() );
    bool ok = f.write( c->fromUnicode( text() ) ) != -1;

    if ( ok )
    {
        setModified( false );
        setProperty( "fileName", fn );
    }
    
    QApplication::restoreOverrideCursor();

    return ok;
}
开发者ID:pasnox,项目名称:monkeystudio2,代码行数:47,代码来源:pEditor.cpp

示例14: qt_encoding_id_for_mib

/*!
  Internal function that initializes the font system.

  \internal
  The font cache and font dict do not alloc the keys. The key is a QString
  which is shared between QFontPrivate and QXFontName.
*/
void QFont::initialize()
{
    extern int qt_encoding_id_for_mib(int mib); // from qfontdatabase_x11.cpp
    QTextCodec *codec = QTextCodec::codecForLocale();
    // determine the default encoding id using the locale, otherwise
    // fallback to latin1 (mib == 4)
    int mib = codec ? codec->mibEnum() : 4;

    // for asian locales, use the mib for the font codec instead of the locale codec
    switch (mib) {
    case 38: // eucKR
        mib = 36;
        break;

    case 2025: // GB2312
        mib = 57;
        break;

    case 113: // GBK
        mib = -113;
        break;

    case 114: // GB18030
        mib = -114;
        break;

    case 2026: // Big5
        mib = -2026;
        break;

    case 2101: // Big5-HKSCS
        mib = -2101;
        break;

    case 16: // JIS7
        mib = 15;
        break;

    case 17: // SJIS
    case 18: // eucJP
        mib = 63;
        break;
    }

    // get the default encoding id for the locale encoding...
    QFontPrivate::defaultEncodingID = qt_encoding_id_for_mib(mib);
}
开发者ID:Fale,项目名称:qtmoko,代码行数:54,代码来源:qfont_x11.cpp

示例15: QActionGroup

void MainWindow::menuCharacterEncodingAboutToShow()
{
	if (!m_characterEncodingGroup)
	{
		QList<int> textCodecs;
		textCodecs << 106 << 1015 << 1017 << 4 << 5 << 6 << 7 << 8 << 82 << 10 << 85 << 12 << 13 << 109 << 110 << 112 << 2250 << 2251 << 2252 << 2253 << 2254 << 2255 << 2256 << 2257 << 2258 << 18 << 39 << 17 << 38 << 2026;

		m_characterEncodingGroup = new QActionGroup(this);
		m_characterEncodingGroup->setExclusive(true);

		QAction *defaultAction = m_ui->menuCharacterEncoding->addAction(tr("Auto Detect"));
		defaultAction->setData(-1);
		defaultAction->setCheckable(true);

		m_characterEncodingGroup->addAction(defaultAction);

		m_ui->menuCharacterEncoding->addSeparator();

		for (int i = 0; i < textCodecs.count(); ++i)
		{
			QTextCodec *codec = QTextCodec::codecForMib(textCodecs.at(i));

			if (!codec)
			{
				continue;
			}

			QAction *textCodecAction = m_ui->menuCharacterEncoding->addAction(Utils::elideText(codec->name(), m_ui->menuCharacterEncoding));
			textCodecAction->setData(textCodecs.at(i));
			textCodecAction->setCheckable(true);

			m_characterEncodingGroup->addAction(textCodecAction);
		}
	}

	const QString encoding = m_windowsManager->getDefaultCharacterEncoding().toLower();

	for (int i = 2; i < m_ui->menuCharacterEncoding->actions().count(); ++i)
	{
		QAction *action = m_ui->menuCharacterEncoding->actions().at(i);

		if (!action)
		{
			continue;
		}

		action->setChecked(encoding == action->text().toLower());

		if (action->isChecked())
		{
			break;
		}
	}

	if (!m_characterEncodingGroup->checkedAction())
	{
		m_ui->menuCharacterEncoding->actions().first()->setChecked(true);
	}
}
开发者ID:mboevink,项目名称:otter,代码行数:59,代码来源:MainWindow.cpp


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