For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
I have a similar code segment as below, and the problem is that when I drag a file from file explorer, the drag over and the drag enter do not allow me to use the DROPEFFECT_NONE. It is overwritten with a DROPEFFECT of DROPEFFECT_COPY.
When the DROPEFFECT_NONE is returned in the OnDragOver event, I get the effect as if it were in DROPEFFECT_COPY. The COLEDragTarget seems to get the correct value back, but then in goes into OLE32 code that I can figure out.
Hi, I am enumerating my network and printing all server name but for mac system it is returning same OS type as windows so i am not able to differentiate machine. i am getting OS type 4099 for mac which is same for windows. also binary conversion is compatible with all predefined macro as i am doing AND with predefined macro.:java
it will print false details for mac and linux system. we have pre defined check for unix os type but for mac we dont have any. and the os type we are getting for mac also similar to on eof win 10 os version.
The second one is the exact opposite of the first one and shows you why you shouldn't mix bool with int: it just creates confusion.
I assume that isEmpty() returns true is the set is empty. So first one says "if set is empty, do not iterate devices". The second one says "if empty is false (that means there are some devices), do not iterate devices". Probably not what you had in mind.
I am trying hard to understand C++ templates.
The following test code works as expected in class constructor.
When I add SAME code to class method - which is is activated via
an event - I get "index" out of range error.
in the method.
is "class variable" why do I have to "initialize " it again in the method?
The "index" is method variable (local) and is initialized to 0. - So why am I running out of index range ?
If you kindly answer the above and refrain from critiquing my coding style I would be grateful.
<pre lang="text"><pre lang="c++">
<pre> // task retrive all locla BT devices
// changed to class variable
QList<QBluetoothHostInfo> information_main = QBluetoothLocalDevice::allDevices();
qDebug() << "QDEBUG TRACE //11/23/2020 # of local BT detetced " << information_main.count();
// add to display
// add test text - output
ui->listWidget->addItem("MainWindow test # of local BT detetced ");
ui->listWidget->addItem("# of local BT detetced ");
//TDOD add conversion
ui->listWidget->addItem("TODO add conversion");
// ui->listWidget->addItem( fromStdString(information_main.count());
// display all adapters
int index = 0;
} while( index != information_main.count() );
qDebug() << "file " << __FILE__;
qDebug() << "function "<<__FUNCTION__;
qDebug() << "@line " << __LINE__;
qDebug()<<"TEMPORARY EXIT ";
The purpose of the post is to identify WHY
the do-while loop works as coded in constructor and fails - run time error - when used in method.
It is , as already posted , a test code.
The task is to read the list of devices returned by
It would be nice if contributions lead to resolve this SPECIFIC problem.
Naming variables, verifying validity of "loop index / count" , pointing out the code is
repeated in class method so far does not addresses my error usage of template.
The only answer I have - it is run time error , not a compiler error as I initially thought. Good point.
No, the other way round. The variable declared in the method will be the one that is used, as it is in the innermost scope. But you should not be declaring the same variable at two scope levels. Just change your code as I suggested to correct the problem. As to the index problem, i suggest you change the do while to a simple while or for loop, to ensure you do not enter the loop if information_main.count() returns zero.
So in other words "index" in constructor and "index" in methods are independent , hence not source of the "out of range error".
That should apply to any variable, including template.
I understand that using same names could be buggy, but I need to verify WHAT is causing the
"out of range error" and IMHO using DIFFERENT names should not be "real " solutions, unless something else is wrong with my implementation of templates.
As I said - this is a test code and the "count" is used to simply verify the list content prior to doing the "do -while " loop and it is > 0.
I have never used "iteration" but planning to employ it after I get the "out of range " error Solved.
Last Visit: 4-Dec-20 10:10 Last Update: 4-Dec-20 10:10