Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] 'source' was not declared in this scope
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] 'source' was not declared in this scope

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.6k 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.
  • I Offline
    I Offline
    iacoposk8
    wrote on last edited by
    #1

    hello everyone! I'm building a class to facilitate me in the use of XML.
    this->type and this->files are properly valorized, but compiling read the following error:
    [code]
    /home/mezzo/Qt/test/mainwindow.cpp:34: error: 'source' was not declared in this scope
    QXmlStreamReader xml(source);
    ^
    [/code]
    I am new to the C ++, but in this case I understand the error but do not know how to solve it. you have ideas?
    thank you.

    [code]
    if(this->type==1){
    QFile* source=this->file;
    }
    if(this->type==0){
    QString source=this->code;
    }
    QXmlStreamReader xml(source);
    [/code]

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you comming from python ?

      From the top of my head:

      @
      QXmlStreamReader xml;
      if(this->type==1){
      xml.setDevice(this->file);
      }
      if(this->type==0){
      xml.addData(this->code);
      }
      @

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • I Offline
        I Offline
        iacoposk8
        wrote on last edited by
        #3

        aaaaaa perfect!
        thank you very much.
        yes, I also come from the python, are oriented more towards the web languages php, javascript etc ...

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You're welcome !

          I'd recommend getting a good book about C++, it'll save you some headaches.

          Also, please update the thread tittle prepending [solved] so other forum users may know a solution has been found :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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