• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ qstrdup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: midiInGetDevCaps

void MidiWinMM::openDevices()
{
	m_inputDevices.clear();
	for( unsigned int i = 0; i < midiInGetNumDevs(); ++i )
	{
		MIDIINCAPS c;
		midiInGetDevCaps( i, &c, sizeof( c ) );
		HMIDIIN hm = 0;
		MMRESULT res = midiInOpen( &hm, i, (DWORD_PTR) &inputCallback,
						(DWORD_PTR) this,
							CALLBACK_FUNCTION );
		if( res == MMSYSERR_NOERROR )
		{
			m_inputDevices[hm] = qstrdup( c.szPname );
			midiInStart( hm );
		}
	}

	m_outputDevices.clear();
	for( unsigned int i = 0; i < midiOutGetNumDevs(); ++i )
	{
		MIDIOUTCAPS c;
		midiOutGetDevCaps( i, &c, sizeof( c ) );
		HMIDIOUT hm = 0;
		MMRESULT res = midiOutOpen( &hm, i, 0, 0, CALLBACK_NULL );
		if( res == MMSYSERR_NOERROR )
		{
			m_outputDevices[hm] = qstrdup( c.szPname );
		}
	}
}
开发者ID:CallisteHanriat,项目名称:lmms,代码行数:31,代码来源:MidiWinMM.cpp


示例2: QObject

VlcInstance::VlcInstance(const QStringList &args,
                         QObject *parent)
    : QObject(parent),
      _vlcInstance(0),
      _status(false)
{
// Convert arguments to required format
#if defined(Q_OS_WIN32) // Will be removed on Windows if confirmed working
    char **argv = (char **)malloc(sizeof(char **) * args.count());
    for (int i = 0; i < args.count(); ++i)
        argv[i] = (char *)qstrdup(args.at(i).toUtf8().data());
#else
    char *argv[args.count()];
    for (int i = 0; i < args.count(); ++i)
        argv[i] = (char *)qstrdup(args.at(i).toUtf8().data());
#endif

    // Create new libvlc instance
    _vlcInstance = libvlc_new(args.count(), argv);

    qRegisterMetaType<Vlc::Meta>("Vlc::Meta");
    qRegisterMetaType<Vlc::State>("Vlc::State");

    VlcError::showErrmsg();

    // Check if instance is running
    if(_vlcInstance) {
        _status = true;
        qDebug() << "VLC-Qt" << libVersion() << "initialised";
        qDebug() << "Using libvlc version:" << version();
    } else {
        qCritical() << "VLC-Qt Error: libvlc failed to load!";
    }
}
开发者ID:alcapo,项目名称:vlc-qt,代码行数:34,代码来源:Instance.cpp


示例3: QObject

VlcInstance::VlcInstance(const QStringList &args, QObject *parent)
    : QObject(parent), _vlcInstance(0)
{
#if defined(Q_OS_WIN32)
    char **argv = (char **)malloc(sizeof(char **) * args.count());
    for (int i = 0; i < args.count(); ++i)
        argv[i] = (char *)qstrdup(args.at(i).toUtf8().data());
#else
    char *argv[args.count()];
    for (int i = 0; i < args.count(); ++i)
        argv[i] = (char *)qstrdup(args.at(i).toUtf8().data());
#endif

    _vlcInstance = libvlc_new(args.count(), argv);

    qRegisterMetaType<Vlc::Meta>("Vlc::Meta");
    qRegisterMetaType<Vlc::State>("Vlc::State");

    VlcError::errmsg();

    if(!_vlcInstance)
    {
        qDebug() << "vlc failed to load!";
        abort();
    }
}
开发者ID:AzanovAA,项目名称:MediaRenamer,代码行数:26,代码来源:vlcinstance.cpp


示例4: compare

static bool compare(const QList<QPair<QString, QString> > &actual, const QueryItems &expected,
                    const char *actualStr, const char *expectedStr, const char *file, int line)
{
    return QTest::compare_helper(actual == expected, "Compared values are not the same",
                                 qstrdup(prettyList(actual)), qstrdup(prettyList(expected).data()),
                                 actualStr, expectedStr, file, line);
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:7,代码来源:tst_qurlquery.cpp


示例5: switch

QStringList KISS::getFileList(packageInfo *p)
{
  QString vb, fn;
  QString name;
  char mode;

  fn = p->getFilename();
  if(!fn.isEmpty())
    mode = 'u';
  else
    mode = 'i';

  QStringList filelist;

  switch(mode)
    {
      ////////////////////////////////////////////////////////////////////////
      // query an installed package!
    case 'i':
      name = p->getProperty("name");

      reader.setup("kiss");
      *reader.proc << "-f" << name;
      if (reader.start(0,FALSE)) {
	char *buffer = qstrdup(reader.buf.ascii());
	char *str = strtok(buffer,"\n");
	if (str) {
	  do {
	    filelist.append(str);
	  } while ((str = strtok(NULL,"\n")));
	}
	delete [] buffer;
      }
      break;

      ////////////////////////////////////////////////////////////////////
      // query an uninstalled package
    case 'u':
      reader.setup("perl");
      *reader.proc << fn << "-f";
      if (reader.start(0,TRUE)) {
	char *buffer = qstrdup(reader.buf.ascii());
	char *str = strtok(buffer,"\n");
	if (str) {
	  do {
	    filelist.append(strdup(str));
	  } while ((str = strtok(NULL,"\n")));
	}
	delete [] buffer;
      }
      break;
    }

  return filelist;
}
开发者ID:iegor,项目名称:kdesktop,代码行数:55,代码来源:kissInterface.cpp


示例6: VideoNowPlayingWindow

void VideosWindow::onVideoSelected(QModelIndex index)
{
    if (index.data(UserRoleHeader).toBool()) return;

    this->setEnabled(false);

    VideoNowPlayingWindow *window = new VideoNowPlayingWindow(this, mafwRegistry);
    window->showFullScreen();

    connect(window, SIGNAL(destroyed()), this, SLOT(onChildClosed()));
    ui->indicator->inhibit();

    playlist->assignVideoPlaylist();
    playlist->clear();

    int selectedRow;
    int indexOffset = 0;
    int videoCount = 0;
    gchar** videoAddBuffer = new gchar*[objectModel->rowCount()+1];

    bool filter = QSettings().value("main/playlistFilter", false).toBool();

    if (filter) {
        selectedRow = index.row();
        for (int i = 0; i < objectProxyModel->rowCount(); i++)
            if (!objectProxyModel->index(i,0).data(UserRoleHeader).toBool())
                videoAddBuffer[videoCount++] = qstrdup(objectProxyModel->index(i,0).data(UserRoleObjectID).toString().toUtf8());
            else if (i < selectedRow)
                ++indexOffset;
    } else {
        selectedRow = objectProxyModel->mapToSource(index).row();
        for (int i = 0; i < objectModel->rowCount(); i++)
            if (!objectModel->item(i)->data(UserRoleHeader).toBool())
                videoAddBuffer[videoCount++] = qstrdup(objectModel->item(i)->data(UserRoleObjectID).toString().toUtf8());
            else if (i < selectedRow)
                ++indexOffset;
    }

    videoAddBuffer[videoCount] = NULL;

    playlist->appendItems((const gchar**) videoAddBuffer);

    for (int i = 0; i < videoCount; i++)
        delete[] videoAddBuffer[i];
    delete[] videoAddBuffer;

    mafwRenderer->gotoIndex(selectedRow-indexOffset);
    window->play();
}
开发者ID:gidzzz,项目名称:openmediaplayer,代码行数:49,代码来源:videoswindow.cpp


示例7: setlocale

//--------------------------------------------------------------------------
char *uniremap_init(char *table)
{
  const char *cur = setlocale(LC_CTYPE, NULL);
  if(!cur) cur = "C"; // PARANOYA
  cur = qstrdup(cur);

#ifdef __UNIX__
  table = create_map("", &lm[0], table);
  lm[1] = lm[0];
#else
  {
    char  s[16];
    int oemcp, acp = get_codepages(&oemcp);
    if ( acp == CP_ACP )      acp   = GetACP();
    if ( oemcp == CP_OEMCP )  oemcp = GetOEMCP();
    qsnprintf(s, sizeof(s), ".%u", oemcp);
    table = create_map(s, &lm[0], table);
    qsnprintf(s, sizeof(s), ".%u", acp);
    create_map(s, &lm[1], NULL);
  }
#endif
  setlocale(LC_CTYPE, cur); // restore default locale
  qfree((void*)cur);
  return(table);
}
开发者ID:nealey,项目名称:vera,代码行数:26,代码来源:uniremap.cpp


示例8: toString

	char* toString(const MapColor& c)
	{
		auto spot_method = QTest::toString(c.getSpotColorMethod());
		auto cmyk_method = QTest::toString(c.getCmykColorMethod());
		auto rgb_method  = QTest::toString(c.getRgbColorMethod());
		
		QByteArray ba;
		ba.reserve(1000);
		ba += "MapColor(";
		ba += QByteArray::number(c.getPriority());
		ba += " ";
		ba += c.getName().toLocal8Bit();
		ba += " (SPOT: ";
		ba += spot_method;
		ba += " ";
		ba += c.getSpotColorName().toLocal8Bit();
		ba += (c.getKnockout() ? " k.o." : " ---");
		ba += " [";
		ba += QByteArray::number(c.getOpacity()*100.0,'f',0);
		ba += "] CMYK: ";
		ba += cmyk_method;
		const MapColorCmyk& cmyk = c.getCmyk();
		ba += QString::fromLatin1(" %1/%2/%3/%4").arg(cmyk.c*100.0,0,'f',1).arg(cmyk.m*100.0,0,'f',1).arg(cmyk.y*100.0,0,'f',1).arg(cmyk.k*100.0,0,'f',1).toLocal8Bit();
		ba += " RGB: ";
		ba += rgb_method;
		const MapColorRgb& rgb = c.getRgb();
		ba += QString::fromLatin1(" %1/%2/%3").arg(rgb.r*255.0,0,'f',0).arg(rgb.g*255.0,0,'f',0).arg(rgb.b*255.0,0,'f',0).toLocal8Bit();
		ba += ")";
		
		delete [] spot_method;
		delete [] cmyk_method;
		delete [] rgb_method;
		
		return qstrdup(ba.data());
	}
开发者ID:02JanDal,项目名称:mapper,代码行数:35,代码来源:map_color_t.cpp


示例9: Files

int Cce152::RecTape(void)
{

    // Display the Save dialog box.
    TapeFileName = QFileDialog::getSaveFileName(
                    mainwindow,
                    "Choose a filename to save under",
                    ".",
                    "Wav Files (*.wav)");
    QFile file(TapeFileName);

    char * str = qstrdup(TapeFileName.toLocal8Bit());

    //if (!file.open(QIODevice::WriteOnly))
    if ((info.ptrFd = fopen(str,"wb"))==NULL)
    {
        AddLog(LOG_TAPE,tr("ERROR: Can't create the wav file."));
        MSG_ERROR(tr("Failed to create file"));
        return 0;
    }

    // create th header
    WriteHeadToWav (10,
                    16000,//pTIMER->pPC->Tape_Base_Freq*2,
                    &info);
    info.bitLen = 0x20;
    info.freq = 16000;//pTIMER->pPC->Tape_Base_Freq*2;
//       ptrFile->bitLen = (freq * 8) / ptrFile->freq ;


    mode = RECORD;

    return (1);
}
开发者ID:TheProjecter,项目名称:pockemul,代码行数:34,代码来源:ce152.cpp


示例10: createStructSig

static trace::StructSig *
createStructSig(const ApiStruct &str, unsigned id)
{
    ApiStruct::Signature aSig = str.signature();

    trace::StructSig *sig = new trace::StructSig();
    sig->id = id;
    sig->name = qstrdup(aSig.name.toLocal8Bit());
    sig->num_members = aSig.memberNames.count();
    char **member_names = new char*[aSig.memberNames.count()];
    sig->member_names = (const char **)member_names;
    for (int i = 0; i < aSig.memberNames.count(); ++i) {
        member_names[i] = qstrdup(aSig.memberNames[i].toLocal8Bit());
    }
    return sig;
}
开发者ID:float-tw,项目名称:apitrace,代码行数:16,代码来源:saverthread.cpp


示例11: hoedown_html_renderer_new

//
// return html rendered markdown of note text
//
QString Note::toMarkdownHtml() {
    hoedown_renderer *renderer = hoedown_html_renderer_new( HOEDOWN_HTML_USE_XHTML, 16 );
    hoedown_document *document = hoedown_document_new(renderer, (hoedown_extensions) HOEDOWN_EXT_SPAN, 16);

    QString str = this->noteText;

    unsigned char *sequence = (unsigned char*)qstrdup( str.toUtf8().constData() );
    int length = strlen( (char*) sequence );

    // return an empty string if the note is empty
    if ( length == 0 )
    {
        return "";
    }

    hoedown_buffer *html = hoedown_buffer_new( length );

    // render markdown html
    hoedown_document_render( document, html, sequence, length );

    // get markdown html
    QString result = QString::fromUtf8( (char*) html->data, html->size );

    /* Cleanup */
    free(sequence);
    hoedown_buffer_free(html);

    hoedown_document_free(document);
    hoedown_html_renderer_free(renderer);

    return result;
}
开发者ID:Amadeus666,项目名称:QOwnNotes,代码行数:35,代码来源:note.cpp


示例12: initImlibParams

void KuickShow::initImlib()
{
    ImData *idata = kdata->idata;
    ImlibInitParams par;
    initImlibParams( idata, &par );

    id = Imlib_init_with_params( x11Display(), &par );
    if ( !id ) {
        initImlibParams( idata, &par );

        qWarning("*** KuickShow: Whoops, can't initialize imlib, trying my own palettefile now.");
        QString paletteFile = locate( "data", "kuickshow/im_palette.pal" );
        // ### - does the qstrdup() cure the segfault in imlib eventually?
        char *file = qstrdup( paletteFile.local8Bit() );
        par.palettefile = file;
        par.flags |= PARAMS_PALETTEFILE;

        qWarning("Palettefile: %s", par.palettefile );

        id = Imlib_init_with_params( x11Display(), &par );

        if ( !id ) {
            QString tmp = i18n("Unable to initialize \"Imlib\".\n"
                               "Start kuickshow from the command line "
                               "and look for error messages.\n"
                               "The program will now quit.");
            KMessageBox::error( this, tmp, i18n("Fatal Imlib Error") );

            FileCache::shutdown();
            ::exit(1);
        }
    }
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:33,代码来源:kuickshow.cpp


示例13: Q_UNUSED

const char* OtrInternal::account_name(const char* account,
                                      const char* protocol)
{
    Q_UNUSED(protocol);
    return qstrdup(m_callback->humanAccountPublic(QString::fromUtf8(account))
                                                 .toUtf8().constData());
}
开发者ID:FlorianFieber,项目名称:psi-plus-plugins,代码行数:7,代码来源:otrinternal.cpp


示例14: qstrdup

packageInfo *KISS::collectInfo(const char *_inp)
{
  QMap<QString, QString> a;

  char *str, *xstr;
  QString qstr;

  char *inp = qstrdup(_inp);
  str = strtok(inp,"\n");
  do {
    xstr = strchr(str,':');
    if (*str == ' ')
      str++;
    if (!strncmp("package",str,7))
      break;
  } while ((str = strtok(NULL,"\n")));

  // parse 'name: text' elements

  if (str) {
    do {
      if (str[0] == 0)
	break;

    xstr = strchr(str,':');
    if (xstr) {
      *xstr++ = 0;
      xstr++;

      for( int i = 0; str[ i ] != '\0'; ++i )
        str[ i ] = tolower( str[ i ] );

      if (*str == ' ')
	str++;

      if (!strcmp("package",str)) {
	a.insert("name", xstr);
      } else if (!strcmp("name",str)) {
	a.insert("summary", xstr);
      } else if (!strcmp("section",str)) {
	a.insert("group", xstr);
      } else if (!strcmp("size",str)) {
	a.insert("file-size", xstr);
      } else if (!strcmp("installed-size",str)) {
	QString str = xstr;
	a.insert("size", str + "000");
      } else {
	a.insert(str, xstr);
      }
    }
    } while ((str = strtok(NULL,"\n")));
  }

  packageInfo *i = new packageInfo(a,this);
  i->packageState = packageInfo::INSTALLED;
  i->fixup();
  delete [] inp;
  return i;

}
开发者ID:iegor,项目名称:kdesktop,代码行数:60,代码来源:kissInterface.cpp


示例15: decode_version

static void decode_version (const char *_buf, int *version,
			    int *modification, int *patch)
  {
    char *buffer = qstrdup(_buf);
    char *buf = buffer;
    *version      = (int) strtoul (buf, &buf, 10);
    *modification = 0;
    *patch        = 0;

    if (*buf == '.')
      {
	++buf;
	*modification = (int) strtoul (buf, &buf, 10);
	if (*buf == '.')
	  {
	    ++buf;
	    *patch = (int) strtoul (buf, &buf, 10);
	  }
      }

    if (*buf != '\0')
      {
	*version      =
	*modification =
	*patch        = 0;
      }

    delete [] buffer;
  }
开发者ID:opieproject,项目名称:opie,代码行数:29,代码来源:runtests.cpp


示例16: defined

bool Q3GCache::insert_other(const char *key, Q3PtrCollection::Item data,
			    int cost, int priority)
{
    if (tCost + cost > mCost) {
	if (!makeRoomFor(tCost + cost - mCost, priority)) {
#if defined(QT_DEBUG)
	    lruList->insertMisses++;
#endif
	    return false;
	}
    }
#if defined(QT_DEBUG)
    Q_ASSERT(keytype != StringKey);
    lruList->inserts++;
    lruList->insertCosts += cost;
#endif
    if (keytype == AsciiKey && copyk)
	key = qstrdup(key);
    if (priority < -32768)
	priority = -32768;
    else if (priority > 32767)
	priority = 32677;
    Q3CacheItem *ci = new Q3CacheItem((void*)key, newItem(data), cost,
				     (short)priority);
    Q_CHECK_PTR(ci);
    lruList->insert(0, ci);
    if (keytype == AsciiKey)
	dict->insert_ascii(key, ci);
    else
	dict->insert_int((long)key, ci);
    tCost += cost;
    return true;
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:33,代码来源:q3gcache.cpp


示例17: m_size

ScopedClangOptions::ScopedClangOptions(const QStringList &options)
    : m_size(options.size())
    , m_rawOptions(new const char*[options.size()])
{
    for (int i = 0 ; i < m_size; ++i)
        m_rawOptions[i] = qstrdup(options[i].toUtf8());
}
开发者ID:AltarBeastiful,项目名称:qt-creator,代码行数:7,代码来源:scopedclangoptions.cpp


示例18: get_vtbl_hint

static char* get_vtbl_hint(int line_num)
{
	current_line_pos = line_num;
	char tag_lines[4096];
	ZeroMemory(tag_lines, sizeof(tag_lines));

	if (isEnabled(vtbl_t_list[line_num].ea_begin))
	{
		int flags = calc_default_idaplace_flags();
		linearray_t ln(&flags);
		idaplace_t pl;
		pl.ea = vtbl_t_list[line_num].ea_begin;
		pl.lnnum = 0;
		ln.set_place(&pl);

		int used = 0;
		int n = ln.get_linecnt();
		for (int i = 0; i < n; i++)
		{
			char buf[MAXSTR];
			char *line = ln.down();
			tag_remove(line, buf, sizeof(buf));
			used += sprintf_s(tag_lines + used, sizeof(tag_lines) - used, "%s\n", buf);
		}

	}

	return qstrdup(tag_lines);
}
开发者ID:andrivet,项目名称:HexRaysCodeXplorer,代码行数:29,代码来源:ObjectExplorer.cpp


示例19: main

int main(int argc, char* argv[])
{
    QT_REQUIRE_VERSION(argc, argv, "5.6.0");

#ifndef Q_OS_WIN
    qInstallMessageHandler(&msgHandler);
#endif

#if defined(Q_OS_LINUX) || defined(__GLIBC__) || defined(__FreeBSD__)
    signal(SIGSEGV, qupzilla_signal_handler);
#endif

    // Hack to fix QT_STYLE_OVERRIDE with QProxyStyle
    const QByteArray style = qgetenv("QT_STYLE_OVERRIDE");
    if (!style.isEmpty()) {
        char** args = (char**) malloc(sizeof(char*) * (argc + 1));
        for (int i = 0; i < argc; ++i)
            args[i] = argv[i];

        QString stylecmd = QL1S("-style=") + style;
        args[argc++] = qstrdup(stylecmd.toUtf8().constData());
        argv = args;
    }

    QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);

    MainApplication app(argc, argv);

    if (app.isClosing())
        return 0;

    app.setStyle(new ProxyStyle);

    return app.exec();
}
开发者ID:Acidburn0zzz,项目名称:qupzilla,代码行数:35,代码来源:main.cpp


示例20: get_demangle_name

// Demangle C++ class name
char* get_demangle_name(ea_t class_addr)
{
	char buf_name[MAXSTR];
	int name_size = get_max_ascii_length(class_addr, ASCSTR_TERMCHR, true);
	get_ascii_contents(class_addr, name_size, ASCSTR_TERMCHR, buf_name, sizeof(buf_name));
	return qstrdup(buf_name);
}
开发者ID:andrivet,项目名称:HexRaysCodeXplorer,代码行数:8,代码来源:ObjectExplorer.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ qstring_from_str函数代码示例发布时间:2022-05-30
下一篇:
C++ qstr_str函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap