Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Missing "type specifier " ?

Missing "type specifier " ?

Scheduled Pinned Locked Moved C / C++ / MFC
databasedebugginglinqfunctionalquestion
10 Posts 5 Posters 0 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    More update Found the crasher - wrong "exit" from "for" loop looking for main menu. Having issues (expected ) using other than first main menu... UPDATE I am posting this to show SOME progress. I did pepper the original with handful of "debug"... ( I need to add comments about what the code does...) So far it works with main menu = 0 and all its sub menus - SUCCESS. I got the sub menu index - so part of my goal is done. Now I need to find the "main menu" index and then find the "crasher".. BTW the author deserves LARGE credit for the code..

    // NOTES placed AFTER menu / submenu
    int MainWindow_Bluetooth::setupLambda ( void )
    {
    #ifdef LAMBDA
    text = "START TASK DEBUG lambda ... ";
    text += Q_FUNC_INFO;
    text += QString::number(__LINE__);
    qDebug() << text;
    #endif
    QObject obj;

    qDebug() << " index\_sub " << index\_sub ; // bogus
    obj.connect(subMenu\[index\_sub\],&QMenu::triggered,subMenu\[index\_sub  \],\[\](QAction\* action)
    

    // obj.connect(subAction[index_sub],QAction::triggered(bool),subAction[index_sub ],[](QAction* action)

    {// lambda
    
        QString path=action->text();
    

    #ifdef LAMBDA
    qDebug() << "TEST need index ?? " << path;
    qDebug()<<"path (sub menu trigger ) "<< path ;
    #endif
    QWidget* parent=action->parentWidget();
    // !!!! submenu trigger index !!!
    path = QString("(%1)").arg(parent->actions().indexOf(action));
    //path += QString("(%1)").arg(parent->actions().indexOf(action));
    //qDebug() << " index ??" << parent->actions().indexOf(actions);

    #ifdef LAMBDA
    qDebug()<<"path (sub menu ) with index TOK "<< path ;
    #endif
    while(parent)
    {
    // main menu
    QMenu* menu=qobject_cast(parent);
    QString title=menu->title();
    #ifdef LAMBDA
    qDebug()<<"title (main menu ) "<< title ;
    #endif
    path+="->"+title;
    qDebug()<<"path (title) "<< path ;
    // ??
    parent=parent->parentWidget();
    #ifdef LAMBDA
    qDebug()<<"TRACE "<< __LINE__ ;
    #endif
    if(parent)
    {
    QMenu* menu=qobject_cast(parent);
    #ifdef LAMBDA
    qDebug()<<"TRACE "<< __LINE__ ;
    #endif
    int index=0;
    const QList actions=menu->actions();
    for(const QAction *act : actions)
    {
    #ifdef LAMBDA
    qDebug()<<"TRACE

    M J R 3 Replies Last reply
    0
    • L Lost User

      More update Found the crasher - wrong "exit" from "for" loop looking for main menu. Having issues (expected ) using other than first main menu... UPDATE I am posting this to show SOME progress. I did pepper the original with handful of "debug"... ( I need to add comments about what the code does...) So far it works with main menu = 0 and all its sub menus - SUCCESS. I got the sub menu index - so part of my goal is done. Now I need to find the "main menu" index and then find the "crasher".. BTW the author deserves LARGE credit for the code..

      // NOTES placed AFTER menu / submenu
      int MainWindow_Bluetooth::setupLambda ( void )
      {
      #ifdef LAMBDA
      text = "START TASK DEBUG lambda ... ";
      text += Q_FUNC_INFO;
      text += QString::number(__LINE__);
      qDebug() << text;
      #endif
      QObject obj;

      qDebug() << " index\_sub " << index\_sub ; // bogus
      obj.connect(subMenu\[index\_sub\],&QMenu::triggered,subMenu\[index\_sub  \],\[\](QAction\* action)
      

      // obj.connect(subAction[index_sub],QAction::triggered(bool),subAction[index_sub ],[](QAction* action)

      {// lambda
      
          QString path=action->text();
      

      #ifdef LAMBDA
      qDebug() << "TEST need index ?? " << path;
      qDebug()<<"path (sub menu trigger ) "<< path ;
      #endif
      QWidget* parent=action->parentWidget();
      // !!!! submenu trigger index !!!
      path = QString("(%1)").arg(parent->actions().indexOf(action));
      //path += QString("(%1)").arg(parent->actions().indexOf(action));
      //qDebug() << " index ??" << parent->actions().indexOf(actions);

      #ifdef LAMBDA
      qDebug()<<"path (sub menu ) with index TOK "<< path ;
      #endif
      while(parent)
      {
      // main menu
      QMenu* menu=qobject_cast(parent);
      QString title=menu->title();
      #ifdef LAMBDA
      qDebug()<<"title (main menu ) "<< title ;
      #endif
      path+="->"+title;
      qDebug()<<"path (title) "<< path ;
      // ??
      parent=parent->parentWidget();
      #ifdef LAMBDA
      qDebug()<<"TRACE "<< __LINE__ ;
      #endif
      if(parent)
      {
      QMenu* menu=qobject_cast(parent);
      #ifdef LAMBDA
      qDebug()<<"TRACE "<< __LINE__ ;
      #endif
      int index=0;
      const QList actions=menu->actions();
      for(const QAction *act : actions)
      {
      #ifdef LAMBDA
      qDebug()<<"TRACE

      M Offline
      M Offline
      Mircea Neacsu
      wrote on last edited by
      #2

      No, the error is on QObject::connect(.... You cannot call a member function of a class(*). You have to insantiate an object of the class and call the member function on that object. Something like:

      QObject obj(/*constructor params*/);
      obj.connect(/*...*/);

      [*] Unless the member function is a static member function. I doubt that is the case here.

      Mircea

      1 Reply Last reply
      0
      • L Lost User

        More update Found the crasher - wrong "exit" from "for" loop looking for main menu. Having issues (expected ) using other than first main menu... UPDATE I am posting this to show SOME progress. I did pepper the original with handful of "debug"... ( I need to add comments about what the code does...) So far it works with main menu = 0 and all its sub menus - SUCCESS. I got the sub menu index - so part of my goal is done. Now I need to find the "main menu" index and then find the "crasher".. BTW the author deserves LARGE credit for the code..

        // NOTES placed AFTER menu / submenu
        int MainWindow_Bluetooth::setupLambda ( void )
        {
        #ifdef LAMBDA
        text = "START TASK DEBUG lambda ... ";
        text += Q_FUNC_INFO;
        text += QString::number(__LINE__);
        qDebug() << text;
        #endif
        QObject obj;

        qDebug() << " index\_sub " << index\_sub ; // bogus
        obj.connect(subMenu\[index\_sub\],&QMenu::triggered,subMenu\[index\_sub  \],\[\](QAction\* action)
        

        // obj.connect(subAction[index_sub],QAction::triggered(bool),subAction[index_sub ],[](QAction* action)

        {// lambda
        
            QString path=action->text();
        

        #ifdef LAMBDA
        qDebug() << "TEST need index ?? " << path;
        qDebug()<<"path (sub menu trigger ) "<< path ;
        #endif
        QWidget* parent=action->parentWidget();
        // !!!! submenu trigger index !!!
        path = QString("(%1)").arg(parent->actions().indexOf(action));
        //path += QString("(%1)").arg(parent->actions().indexOf(action));
        //qDebug() << " index ??" << parent->actions().indexOf(actions);

        #ifdef LAMBDA
        qDebug()<<"path (sub menu ) with index TOK "<< path ;
        #endif
        while(parent)
        {
        // main menu
        QMenu* menu=qobject_cast(parent);
        QString title=menu->title();
        #ifdef LAMBDA
        qDebug()<<"title (main menu ) "<< title ;
        #endif
        path+="->"+title;
        qDebug()<<"path (title) "<< path ;
        // ??
        parent=parent->parentWidget();
        #ifdef LAMBDA
        qDebug()<<"TRACE "<< __LINE__ ;
        #endif
        if(parent)
        {
        QMenu* menu=qobject_cast(parent);
        #ifdef LAMBDA
        qDebug()<<"TRACE "<< __LINE__ ;
        #endif
        int index=0;
        const QList actions=menu->actions();
        for(const QAction *act : actions)
        {
        #ifdef LAMBDA
        qDebug()<<"TRACE

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        Certainly looks to me that at a minimum you are missing a paren in the first line/statement.

        K 1 Reply Last reply
        0
        • J jschell

          Certainly looks to me that at a minimum you are missing a paren in the first line/statement.

          K Offline
          K Offline
          k5054
          wrote on last edited by
          #4

          That's what I thought too, but then I saw the comment //lambda just after the opening brace. I think that the following code is all a lambda expression as a parameter to the QObject::connect() call. I think the OP could have cleaned up the submission with something like

          QObject::connect(&MainWindow_Bluetooth::subMenu,&QMenu::triggered,&MainWindow_Bluetooth::subMenu,[](QAction* action){ /* lamda, body omitted */ });

          "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

          1 Reply Last reply
          0
          • L Lost User

            More update Found the crasher - wrong "exit" from "for" loop looking for main menu. Having issues (expected ) using other than first main menu... UPDATE I am posting this to show SOME progress. I did pepper the original with handful of "debug"... ( I need to add comments about what the code does...) So far it works with main menu = 0 and all its sub menus - SUCCESS. I got the sub menu index - so part of my goal is done. Now I need to find the "main menu" index and then find the "crasher".. BTW the author deserves LARGE credit for the code..

            // NOTES placed AFTER menu / submenu
            int MainWindow_Bluetooth::setupLambda ( void )
            {
            #ifdef LAMBDA
            text = "START TASK DEBUG lambda ... ";
            text += Q_FUNC_INFO;
            text += QString::number(__LINE__);
            qDebug() << text;
            #endif
            QObject obj;

            qDebug() << " index\_sub " << index\_sub ; // bogus
            obj.connect(subMenu\[index\_sub\],&QMenu::triggered,subMenu\[index\_sub  \],\[\](QAction\* action)
            

            // obj.connect(subAction[index_sub],QAction::triggered(bool),subAction[index_sub ],[](QAction* action)

            {// lambda
            
                QString path=action->text();
            

            #ifdef LAMBDA
            qDebug() << "TEST need index ?? " << path;
            qDebug()<<"path (sub menu trigger ) "<< path ;
            #endif
            QWidget* parent=action->parentWidget();
            // !!!! submenu trigger index !!!
            path = QString("(%1)").arg(parent->actions().indexOf(action));
            //path += QString("(%1)").arg(parent->actions().indexOf(action));
            //qDebug() << " index ??" << parent->actions().indexOf(actions);

            #ifdef LAMBDA
            qDebug()<<"path (sub menu ) with index TOK "<< path ;
            #endif
            while(parent)
            {
            // main menu
            QMenu* menu=qobject_cast(parent);
            QString title=menu->title();
            #ifdef LAMBDA
            qDebug()<<"title (main menu ) "<< title ;
            #endif
            path+="->"+title;
            qDebug()<<"path (title) "<< path ;
            // ??
            parent=parent->parentWidget();
            #ifdef LAMBDA
            qDebug()<<"TRACE "<< __LINE__ ;
            #endif
            if(parent)
            {
            QMenu* menu=qobject_cast(parent);
            #ifdef LAMBDA
            qDebug()<<"TRACE "<< __LINE__ ;
            #endif
            int index=0;
            const QList actions=menu->actions();
            for(const QAction *act : actions)
            {
            #ifdef LAMBDA
            qDebug()<<"TRACE

            R Offline
            R Offline
            RedDk
            wrote on last edited by
            #5

            I suggest looking through all your code (there really is no "points" when something comes to an "action" especially when ALL of the code is not available) for "typedef". Then, assuming these errors are sallying forth from the mingw/gnu/etc compiler you're using, and have no code associated with them to differentiate one from the other, change any typedefs of the form: (this only an example, not the code you have) std::vector::size_type To std::vector::size_type size See if any errors go away.

            L 1 Reply Last reply
            0
            • R RedDk

              I suggest looking through all your code (there really is no "points" when something comes to an "action" especially when ALL of the code is not available) for "typedef". Then, assuming these errors are sallying forth from the mingw/gnu/etc compiler you're using, and have no code associated with them to differentiate one from the other, change any typedefs of the form: (this only an example, not the code you have) std::vector::size_type To std::vector::size_type size See if any errors go away.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Thanks, the code is an example I found, so I am just starting to modify it for my use. I stopped when I received the error. I actually got more , but I just do not see how to fix the "action". The "problem" is - the original error "pointed " on "connect" and this error "points " on "action" Let me work on this...maybe I can actually clean up the whole "lambda".

              L 1 Reply Last reply
              0
              • L Lost User

                Thanks, the code is an example I found, so I am just starting to modify it for my use. I stopped when I received the error. I actually got more , but I just do not see how to fix the "action". The "problem" is - the original error "pointed " on "connect" and this error "points " on "action" Let me work on this...maybe I can actually clean up the whole "lambda".

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Here is modified , incomplete , code .

                int MainWindow_Bluetooth::setupLambda ( void )
                {
                #ifdef LAMBDA
                text = "START TASK DEBUG LAMBDA... ";
                text += Q_FUNC_INFO;
                text += QString::number(__LINE__);
                qDebug() << text;
                #endif
                QObject obj(); // no parameters , all variables are class members , is that OK ?

                obj.connect(&subMenu\[index\],&QMenu::triggered,&subMenu\[index\],\[\](QAction\* action)
                {// lambda
                
                }// lambda
                );
                

                #ifdef LAMBDA
                text = "END TASK DEBUG LAMBDA... ";
                text += Q_FUNC_INFO;
                text += QString::number(__LINE__);
                qDebug() << text;
                #endif

                return 0;
                

                }

                Now I am getting this error

                /mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:92: error: base of member reference is a function; perhaps you meant to call it with no arguments?

                I am still lost... (I do not like lambda - too cryptic )

                M K 2 Replies Last reply
                0
                • L Lost User

                  Here is modified , incomplete , code .

                  int MainWindow_Bluetooth::setupLambda ( void )
                  {
                  #ifdef LAMBDA
                  text = "START TASK DEBUG LAMBDA... ";
                  text += Q_FUNC_INFO;
                  text += QString::number(__LINE__);
                  qDebug() << text;
                  #endif
                  QObject obj(); // no parameters , all variables are class members , is that OK ?

                  obj.connect(&subMenu\[index\],&QMenu::triggered,&subMenu\[index\],\[\](QAction\* action)
                  {// lambda
                  
                  }// lambda
                  );
                  

                  #ifdef LAMBDA
                  text = "END TASK DEBUG LAMBDA... ";
                  text += Q_FUNC_INFO;
                  text += QString::number(__LINE__);
                  qDebug() << text;
                  #endif

                  return 0;
                  

                  }

                  Now I am getting this error

                  /mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:92: error: base of member reference is a function; perhaps you meant to call it with no arguments?

                  I am still lost... (I do not like lambda - too cryptic )

                  M Offline
                  M Offline
                  Mircea Neacsu
                  wrote on last edited by
                  #8

                  You are getting somewhere. Try this:

                  QObject obj; //if constructor doesn't require parameters there are no empty parenthesis

                  Salvatore Terress wrote:

                  (I do not like lambda - too cryptic )

                  Tough! :D

                  Mircea

                  1 Reply Last reply
                  0
                  • L Lost User

                    Here is modified , incomplete , code .

                    int MainWindow_Bluetooth::setupLambda ( void )
                    {
                    #ifdef LAMBDA
                    text = "START TASK DEBUG LAMBDA... ";
                    text += Q_FUNC_INFO;
                    text += QString::number(__LINE__);
                    qDebug() << text;
                    #endif
                    QObject obj(); // no parameters , all variables are class members , is that OK ?

                    obj.connect(&subMenu\[index\],&QMenu::triggered,&subMenu\[index\],\[\](QAction\* action)
                    {// lambda
                    
                    }// lambda
                    );
                    

                    #ifdef LAMBDA
                    text = "END TASK DEBUG LAMBDA... ";
                    text += Q_FUNC_INFO;
                    text += QString::number(__LINE__);
                    qDebug() << text;
                    #endif

                    return 0;
                    

                    }

                    Now I am getting this error

                    /mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:92: error: base of member reference is a function; perhaps you meant to call it with no arguments?

                    I am still lost... (I do not like lambda - too cryptic )

                    K Offline
                    K Offline
                    k5054
                    wrote on last edited by
                    #9

                    Salvatore Terress wrote:

                    (I do not like lambda - too cryptic )

                    There's nothing that says you have to use a lambda. Sometimes, the capture variables are very useful, but if you'd rather write a normal function, the go ahead and do so. Sometimes a function object works best: [Function Objects in the C++ Standard Library | Microsoft Learn](https://learn.microsoft.com/en-us/cpp/standard-library/function-objects-in-the-stl?view=msvc-170)

                    "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

                    L 1 Reply Last reply
                    0
                    • K k5054

                      Salvatore Terress wrote:

                      (I do not like lambda - too cryptic )

                      There's nothing that says you have to use a lambda. Sometimes, the capture variables are very useful, but if you'd rather write a normal function, the go ahead and do so. Sometimes a function object works best: [Function Objects in the C++ Standard Library | Microsoft Learn](https://learn.microsoft.com/en-us/cpp/standard-library/function-objects-in-the-stl?view=msvc-170)

                      "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      I am using this code example to get more familiar with "connect". I am at 3rd attempt to write easy to understand way to process menu / submenu code. I had it working at one time, for one menu. Now I am adding more menu and now my submenus are "multiple selection" instead of single submenu. This code example seems to have that "fixed" , but now it is using lambda...

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups