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. Whar is this error saying?
Forum Updated to NodeBB v4.3 + New Features

Whar is this error saying?

Scheduled Pinned Locked Moved Unsolved C++ Gurus
6 Posts 5 Posters 857 Views 2 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    So - it is an error , but why compiler complains about BOTH "()" ?

    Please no other subject s - I just want to know this about both "()" .

    /mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth.cpp:3665: error: expected '(' for function-style cast or type construction
    mainwindow_Bluetooth.cpp:3665:34: error: expected '(' for function-style cast or type construction
     connect(tempmenu, triggered(bool), this, &MainWindow_Bluetooth::openSerialPort);
                                 ~~~~^
    
    Christian EhrlicherC 1 Reply Last reply
    0
    • A Anonymous_Banned275

      So - it is an error , but why compiler complains about BOTH "()" ?

      Please no other subject s - I just want to know this about both "()" .

      /mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth.cpp:3665: error: expected '(' for function-style cast or type construction
      mainwindow_Bluetooth.cpp:3665:34: error: expected '(' for function-style cast or type construction
       connect(tempmenu, triggered(bool), this, &MainWindow_Bluetooth::openSerialPort);
                                   ~~~~^
      
      Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @AnneRanch said in Whar is this error saying?:

      but why compiler complains about BOTH "()" ?

      Because you still don't understand how signals and slots work... the second argument must be a pointer member function as you already did for the forth parameter.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      Axel SpoerlA 1 Reply Last reply
      3
      • Christian EhrlicherC Christian Ehrlicher

        @AnneRanch said in Whar is this error saying?:

        but why compiler complains about BOTH "()" ?

        Because you still don't understand how signals and slots work... the second argument must be a pointer member function as you already did for the forth parameter.

        Axel SpoerlA Offline
        Axel SpoerlA Offline
        Axel Spoerl
        Moderators
        wrote on last edited by
        #3

        @AnneRanch
        Luckily, menu creation is still in short-term memory. So I have a remote idea, what tempmenuactually is ;-)

        => change the line to

         connect(tempmenu, &QMenu::triggered, this, &MainWindow_Bluetooth::openSerialPort);
        

        Software Engineer
        The Qt Company, Oslo

        A 1 Reply Last reply
        0
        • Axel SpoerlA Axel Spoerl

          @AnneRanch
          Luckily, menu creation is still in short-term memory. So I have a remote idea, what tempmenuactually is ;-)

          => change the line to

           connect(tempmenu, &QMenu::triggered, this, &MainWindow_Bluetooth::openSerialPort);
          
          A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #4

          @Axel-Spoerl Thanks , I wad actually triggering on wrong action before. I guess I will never know why I how to read the "() " error to correct my code.
          .
          ( I guess I posted this wrong and despite my request (i GOT "how to write connect advises I DID NOT ASK FOR" .

          Thanks Axel

          JonBJ J.HilkJ 2 Replies Last reply
          0
          • A Anonymous_Banned275

            @Axel-Spoerl Thanks , I wad actually triggering on wrong action before. I guess I will never know why I how to read the "() " error to correct my code.
            .
            ( I guess I posted this wrong and despite my request (i GOT "how to write connect advises I DID NOT ASK FOR" .

            Thanks Axel

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by JonB
            #5

            @AnneRanch
            The error message you got when you wrote triggered(bool) in your connect() is simply because the compiler cannot match any of the available overloads of connect() to one which would accept anything like triggered(bool) as the actual parameter. In itself, like many C++ compiler errors the wording is a bit abstruse/not terribly helpful, because the language is complicated.

            1 Reply Last reply
            0
            • A Anonymous_Banned275

              @Axel-Spoerl Thanks , I wad actually triggering on wrong action before. I guess I will never know why I how to read the "() " error to correct my code.
              .
              ( I guess I posted this wrong and despite my request (i GOT "how to write connect advises I DID NOT ASK FOR" .

              Thanks Axel

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @AnneRanch said in Whar is this error saying?:

              Thanks , I wad actually triggering on wrong action before. I guess I will never know why I how to read the "() " error to correct my code.

              The compiler is actually exactly telling you why it has a problem with the (missing) brackets, I'll quote the part:

              cpp-compiler said in mainwindow_Bluetooth.cpp

              error: expected '(' for function-style cast or type construction

              it thinks your bool is an attempt of you to cast something to an boolean and it thinks the silly programmer forgot to add the bracket and the actual variable that is supposed to be cast.

              something like this:

              int a = 0;
              auto b = bool(a);
              

              or in your particular case:

              void triggered(bool variable) { qDebug() << variable }
              ....
              int a = 0;
              triggered(bool(a));
              

              The compiler doesn't know that function style cast do only the other people, true c++ programers don't use it at all.


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              1

              • Login

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