Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. 这一段代码错在哪里,执行的时候会出问题
Forum Updated to NodeBB v4.3 + New Features

这一段代码错在哪里,执行的时候会出问题

Scheduled Pinned Locked Moved Chinese
7 Posts 6 Posters 4.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    figo
    wrote on last edited by
    #1

    @QString srcimgfilename;
    QString rawdatafilename;
    QStringList filelist;
    filelist = QFileDialog::getOpenFileNames(this,tr("选择文件"),".",tr("Text files (.txt);;XML files (.xml)"));
    QStringList::const_iterator it = filelist.constBegin();
    while(it != filelist.constEnd())
    {
    leftpointfilename = (*it).toLocal8Bit;
    std::cout<<(*it).toLocal8Bit().constData()<<std::endl;
    ++it;
    rightpointfilename = (*it).toLocal8Bit;
    std::cout<<(*it).toLocal8Bit().constData()<<std::endl;
    }@

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kenier
      wrote on last edited by
      #2

      @Text files (.txt);;XML files (.xml)@

      1 Reply Last reply
      0
      • F Offline
        F Offline
        figo
        wrote on last edited by
        #3

        当我想取出文件夹里面选择的部分文件时,程序会在while循环里面出不来

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jiangcaiyang
          wrote on last edited by
          #4

          尝试不用iterator,而用更加方便的foreach伪关键字。
          @
          foreach( QString fileName, filelist )
          {
          std::cout << qPrintable( fileName ) << '\n';
          }
          @

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pridesky
            wrote on last edited by
            #5

            (*it).toLocal8Bit;?????
            toLocal8Bit不是接口吗?不是应该(*it).toLocal8Bit()吗?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sengyy
              wrote on last edited by
              #6

              it ++ 放在 循环的最后面试试看行不行

              1 Reply Last reply
              0
              • L Offline
                L Offline
                LJoker
                wrote on last edited by
                #7

                永远不要写:(*it).toLocal8Bit().constData();这样的代码!
                toLocal8Bit()是产生临时对象,constData返回一个临时对象的指针,结果呢。。。。

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved