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. for function-style cast or type construction error ?
Forum Updated to NodeBB v4.3 + New Features

for function-style cast or type construction error ?

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

    I am trying to implement Bluetooth pairing using QBluetoothLocalDevice
    I do not fully understand the
    QBluetoothLocalDevice localDevice; line

    but I got the iteration "for loop " working.

    I do not understand the error thrown by using
    localDevice.requestPairing...

    Can anybody please help me to fix this ?

            QBluetoothLocalDevice localDevice;
            //powerOn if not already
            localDevice.powerOn();
    
    
            text = localDevice.name();
            qDebug() << text;
    
    
            text = localDevice.address().toString();
            qDebug() << text;
    
            for (const auto & adapter : localDevice.allDevices())
            {
                text = " TASK for loop...";
                qDebug() << text;
    
                text = " TASK continue...";
                text += adapter.name();
                qDebug() << text;
                m_ui->plainTextEdit_4->appendPlainText(text);
    
                text = " TASK continue...";
                text += adapter.address().toString();
                qDebug() << text;
                m_ui->plainTextEdit_4->appendPlainText(text);
    
                localDevice.requestPairing(adapter.address(), QBluetoothLocalDevice::Pairing)); this  fails 
            }
    

    Error

    /mnt/RAID_124/PROJECTS_May8_BASE_MDI_/terminal_Serial/settingsdialog.cpp:1608: error: expected '(' for function-style cast or type construction
    settingsdialog.cpp:1608:89: error: expected '(' for function-style cast or type construction
                localDevice.requestPairing(adapter.address(), QBluetoothLocalDevice::Pairing));
                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
    
    JonBJ 1 Reply Last reply
    0
    • A Anonymous_Banned275

      I am trying to implement Bluetooth pairing using QBluetoothLocalDevice
      I do not fully understand the
      QBluetoothLocalDevice localDevice; line

      but I got the iteration "for loop " working.

      I do not understand the error thrown by using
      localDevice.requestPairing...

      Can anybody please help me to fix this ?

              QBluetoothLocalDevice localDevice;
              //powerOn if not already
              localDevice.powerOn();
      
      
              text = localDevice.name();
              qDebug() << text;
      
      
              text = localDevice.address().toString();
              qDebug() << text;
      
              for (const auto & adapter : localDevice.allDevices())
              {
                  text = " TASK for loop...";
                  qDebug() << text;
      
                  text = " TASK continue...";
                  text += adapter.name();
                  qDebug() << text;
                  m_ui->plainTextEdit_4->appendPlainText(text);
      
                  text = " TASK continue...";
                  text += adapter.address().toString();
                  qDebug() << text;
                  m_ui->plainTextEdit_4->appendPlainText(text);
      
                  localDevice.requestPairing(adapter.address(), QBluetoothLocalDevice::Pairing)); this  fails 
              }
      

      Error

      /mnt/RAID_124/PROJECTS_May8_BASE_MDI_/terminal_Serial/settingsdialog.cpp:1608: error: expected '(' for function-style cast or type construction
      settingsdialog.cpp:1608:89: error: expected '(' for function-style cast or type construction
                  localDevice.requestPairing(adapter.address(), QBluetoothLocalDevice::Pairing));
                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @AnneRanch If you count your parentheses you will see you have the wrong number.

      A 1 Reply Last reply
      1
      • JonBJ JonB

        @AnneRanch If you count your parentheses you will see you have the wrong number.

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        @JonB Thanks but no, I had a wrong syntax.
        SOLVED

        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