Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Strange Error message
Qt 6.11 is out! See what's new in the release blog

Strange Error message

Scheduled Pinned Locked Moved C++ Gurus
16 Posts 3 Posters 7.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.
  • D Offline
    D Offline
    Dn588
    wrote on last edited by
    #5

    Tried that but still no change...
    Thanks for taking a look

    my code:

    https://www.dropbox.com/sh/qkujdbs0trjksvq/AADEV3y0xMyQ__WyP6IkzLOha?dl=0

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

      Hi,

      You can't copy QObject derived class so addToList should have a pointer to staff as parameter

      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
      • D Offline
        D Offline
        Dn588
        wrote on last edited by
        #7

        Thanks a lot SGaist

        I now get another error I don't understand...

        error: expected unqualified-id before if'

        At the code:

        @
        QFile file("staff.txt");

        if (!file.open(QIODevice:: WriteOnly | QIODevice:: Text))
        return;
        @

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

          Is this code located in a function ?

          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
          • D Offline
            D Offline
            Dn588
            wrote on last edited by
            #9

            No it's not could that be it?

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

              You can't write code freely anywhere in a file in C/C++ It needs to be inside a function/method.

              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
              • D Offline
                D Offline
                Dn588
                wrote on last edited by
                #11

                Thanks I moved it into a function. now i'm getting an error invalid conversion from int to char* in the following function @QString staff::toString() {
                return QString("Name: %1 \n Birth Date: %2 \n Staff Type: %3 \n \n").arg(s_name).arg(s_birthDate.toString('yyyyMMdd').arg(getTypeString()));
                }@

                there's no int in this function though? Could it be the enum s_type? I created a function getTypeString @
                staff::getTypeString() {
                return property("Type").toString();
                }
                that's supposed to return a QString...

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

                  The only error I see currently is that you have a misplace arg. You attached your third parameter to the s_birthDate.toString call

                  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
                  • D Offline
                    D Offline
                    Dn588
                    wrote on last edited by
                    #13

                    So should the parameters start at %0?

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

                      Nop, that part is fine

                      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
                      • D Offline
                        D Offline
                        Dn588
                        wrote on last edited by
                        #15

                        which third parameter did I attach to s_birthDate.toString()?

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

                          @
                          QString("Name: %1 \n Birth Date: %2 \n Staff Type: %3 \n \n")
                          .arg(s_name) << correct
                          .arg(s_birthDate.toString('yyyyMMdd').arg(getTypeString() << arg of toString rather than arg for QString()
                          @

                          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