|
A QBluetoothAddress is presumably a bluetooth device address. So a 48-bit integer essentially, but with a specific interpretation as being a bluetooth address.
It being "an address" is orthogonal to being passed by reference or by value or pointers or anything like that. With the method signature being like that though, it will be passed by value.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
This: QBluetoothAddress Class | Qt Bluetooth 5.15.13[^], the key detail being:
Quote: This class holds a Bluetooth address in a platform- and protocol-independent manner. .
But your function definition is incomplete, and would more likely be something like:
void SettingsDialog::pairingDone(QBluetoothAddress& qbaddr, QBluetoothLocalDevice::Pairing& pair)
where qbaddr is a reference to (i.e. address of) a QBluetoothAddress object, and pair is a reference to a QBluetoothLocalDevice::Pairing object, see QBluetoothLocalDevice Class | Qt Bluetooth 6.5.0[^].
It seems to me the main issue you need to address is gaining a good understanding of C++ and its syntax. The same probably holds true for Qt and its Bluetooth classes.
|
|
|
|
|
Member 14968771 wrote: All I get is "passing by value or by reference" - so what are the parameters actually passed to "pairingDone" ?
That refers to how they are passed.
You are asking what they are.
You have a method. It takes parameters.
To use the method you must do the following
1. Understand the execution flow required to use the method
2. Understand the type of the parameters.
3. Understand how to create the parameters.
4. Understand what the method does.
Member 14968771 wrote: point me to good resource to learn something about the syntax
Based on what you posted you do not have enough knowledge about C++ to begin to use the function you posted above. (Using bluetooth is not easy for an experienced programmer.)
Your questions are valid but even if someone provided an exact answer you would still need more information to use everything else required to correctly use the method that you posted.
But if you want you can use the following in google. Those examples do explain what the first parameter is and what to do with it. But then you need the other parameter. And everything else I mentioned above.
QBluetoothAddress examples
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Member 14968771 wrote: I am NOT and never claim to be an expert in C++.
No one ever said you did, but your lack of understanding of the language means that you are wasting your time trying to work this project which is obviously well beyond your knowledge level.
Member 14968771 wrote: Here is what I got from Mrs Google example
void SettingsDialog::pairingDone(QBluetoothAddress ,QBluetoothLocalDevice::Pairing)
Where exactly did you get that, because as it stands it makes no sense?
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
You seem to be under the impression that everybody here is both out to get you and here to do your work for you: neither is the case.
Unfortunately for you everybody here is a volunteer, and most do not take kindly to having their time wasted and abuse HURLED at them and respond in an appropriate manner.
I hope that you can take your time here as a learning experience, but from your question and comment history, I guess that is unlikely. If this has been your attitude on the "other sites" that threw you off as well, I can understand why they didn't want you around either ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Member 14968771 wrote: PLEASE QUIT harassing me about my "lack of basic knowledge" - such continuing (!) harassment just does not fit this forum purpose . ( read how to answer the question INSTRUCTIONS and follow them PLEASE ) I am just learning as I go because I believe that it is better to start with coding a real application and if it does not perform as expected then RTFM and or ask for help.
I am not harassing you.
I am however trying to make sense of what you are asking from the context of what you posted.
I have about 15 years of C++ experience and with C experience before that (but quite a few years ago) along with with decades of experience in other programming language.
With that experience I would expect that getting bluetooth code to work would be a challenge for me.
Your lack of experience in understand fundamentals of programming, not just in C++, means that attempting to explain everything that you would need to know how to proceed with a bluetooth project is just not worth the time to even start. That is not a reflection on you. Anyone and everyone, even a super genius, would still need to know more fundamentals before they could even start.
But even so I did outline exactly what you would need to do to program the project.
Member 14968771 wrote: all I am asking - which way is up and WHY ?
No idea what you are asking. But my previous outline provides the framework for which you would need to proceed.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Well, the documentation[^] is written in English.
You may also find some tutorials on the web, check out, for instance: C++ Ranged for Loop (With Examples)[^].
Finally, in your scenario, it could be
QList<QBluetoothHostInfo> adapters = QBluetoothLocalDevice::allDevices()
for (auto & adapter : adapters)
{
} or
QList<QBluetoothHostInfo> adapters = QBluetoothLocalDevice::allDevices()
for (const auto & adapter : adapters)
{
}
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
In some ways it is just like an ordinary for loop. The difference being that the variable is intialised and incremented automatically. Given the following:
for (int foo : arayOfIntegers)
{
}
Think of it as:
foreach item in arayOfIntegers
BEGIN
set foo to the value of the next item in the list
do stuff with foo
END
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
It is just a loop variable, the same as in a standard for loop.
|
|
|
|
|
You should be thinking in terms of containers, elements and iterators. While the ranged for loop does work for POD arrays, the dimension has to be known at compile time. For example
void showarray(int *arr)
{
for(i : arr)
std::cout << i << ' ';
std::cout << '\n';
} will not compile, since the dimension of arr is not known. On the other hand, if the compiler can deduce the size of the array, then a ranged for loop may be used with a POD array:
#include <iostream>
int main()
{
std::cout << "Enter size : ";
int n;
std::cin >> n;
int arr[n];
for(int i = 0; i < n; ++i) {
arr[i] = i;
}
for( auto x : arr) {
std::cout << x << ' ';
}
std :: cout << '\n';
} Here the compiler can deduce the dimension of the array arr and this program compiles and executes as expected. In the general case, though the ranged for loop works with containers which implement begin() and end() . That's true for STL containers, and lots of other container like objects from other libraries.
Addendum In addition to begin() and end() the container also needs to implement iterators. In the STL, you cannot use a ranged for loop with a stack , queue or priority_queue
Keep Calm and Carry On
modified 10-May-23 13:40pm.
|
|
|
|
|
A culture of entitlement.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
No idea why your question was down voted. So I up voted it.
Sometimes I can guess at skill level so it helps to frame an answer but I am unsure of your skill level. (I am using 'skill' intentionally in a very ambiguous way here.)
Do you understand what the following loop construct does?
for (int i = 1; i <= 5; ++i)
If you do not then I suggest that you experiment with that for a while. And look up different ways to structure it including replacing it with a while loop.
The structure that you asked about is just syntactic sugar that ends up implementing something similar to the above. So understanding it first helps.
|
|
|
|
|
Hello,
I'm a beginner in C++ and SFML for game creation under linux(Pop!_OS 22.04 LTS). I tested the code on the official SFML website, everything seems to work but the title bar doesn't display; it's the same with other codes. I need your help, please. Here is an example of a code I tested:
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "SFML works!", sf::Style::Titlebar);
sf::Event ev;
while(window.isOpen()){
while(window.pollEvent(ev)){
switch(ev.type){
case sf::Event::Closed:
window.close();
break;
case sf::Event::KeyPressed:
if(ev.key.code == sf::Keyboard::Escape){
window.close();
break;
}
default:
break;
}
}
window.clear(sf::Color::Blue);
window.display();
}
return 0;
}
|
|
|
|
|
Your question is about SFML rather than C++. You are more likely to get an answer at SFML[^]
|
|
|
|
|
Ok. I'll post it in SFML forum.
|
|
|
|
|
When you both create a pointer and allocate memory (with “new”) that the pointer will point to, it’s almost like creating an invisible variable. When you want to dispose if you delete the pointer the case is solved.
However if you declare a variable and assign the variable address to a pointer, later if you use “delete” on the pointer will that delete the content of the variable too?
modified 23-Apr-23 14:15pm.
|
|
|
|
|
If you're responsible for managing memory you've allocated, then freeing it means it's gone; regardless of which part of your app did it. i.e. you're the one "counting the references".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
|
In case 1 you are creating a new block of dynamic memory space. When you call delete on the pointer it returns the memory space to the free pool, but the pointer still exists (until it goes out of scope, or the program ends).
In case 2 the pointer is referring to memory space that already exists, i.e. it was not created by new , so you cannot call delete on it.
|
|
|
|
|
Thank you to everyone for helping
modified 24-Apr-23 4:51am.
|
|
|
|