|
Voluntarily removed - wrong forum.
modified 27-Jan-24 16:00pm.
|
|
|
|
|
Salvatore Terress wrote: To make sure for people who "do not get it" - if you are not wiling to help,
please do not respond..
Kindly stop giving orders. As you have been repeatedly told, just post the question. If the answer is not to your exacting requirements, then you have two choices:
1. Politely ask for clarification.
2. Ignore it.
|
|
|
|
|
I tried placing the UpdateGame() function inside the window message processing loop but the execution never reaches that spot
while (WM_QUIT != msg.message)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
UpdateGame();
}
}
I`m trying to mix code from two different tutorials which might be the cause of the problem. Bellow is what the initial message processing loop looked like.
while (GetMessage(&msg, nullptr, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
|
|
|
|
|
At a guess PeekMessage() is always returning true. If you want UpdateGame() to always be called then remove it from the else block:
while (WM_QUIT != msg.message)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
UpdateGame();
}
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
|
|
|
|
|
Thanks for advice, I’ll give it a try
modified 27-Jan-24 11:28am.
|
|
|
|
|
I was told that if I want to call invalidate rectangle the space between begin paint and end paint is not a good place to set the dimensions of rectangles, hence I`m trying to create an update function for my game, a place where I can set the position and dimension of rectangles and also compute all sorts of other things required in the game. I borrowed this code from a DirectX tutorial
while (WM_QUIT != msg.message)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
UpdateGame();
}
}
but the execution never reaches UpdateGame(). Could you please help me out find a place for UpdateGame()?
modified 26-Jan-24 6:35am.
|
|
|
|
|
You need to provide more details about what you are trying to do here. Calling UpdateGame in the message loop as you show, will only work if there are no messages in the queue. And given the way Windows operates, this is not very likely. The only thing you should do in your WM_PAINT handler, is to update the screen. All calculations and measurements should be performed elsewhere.
|
|
|
|
|
Original post edited, I hope it makes sense now
|
|
|
|
|
I just ran a quick test and the call to UpdateGame does indeed get called many times in a simple Window. You need to do some more debugging to find out why that does not happen in your code.
|
|
|
|
|
Wow, you're a game developer, now!
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
void UpdateGame()
{
MessageBox(hWnd, "Doing the update", "Game", MB_OK);
}
|
|
|
|
|
|
The second line of code does not compile and I get a ton of "helpful" messages.
I am asking the forum to help me to understand the messages.
I am not asking for RTFM...
If somebody is willing to help I will post the errors.
QAction tempAction;
subMenu[index]->addAction(" test ");
subMenu[index]->addAction(tempAction.setCheckable(true));
|
|
|
|
|
Posting such a question without the error message is not very helpful. Please make sure you post all the relevant information.
|
|
|
|
|
Don't make a post with a teensy bit of code and no errors, then ask "is someone willing to help?" Because if you don't supply ALL of the information on the problem, the answer is going to be NO. All you're doing is wasting time because now you have to wait for an answer of "Sure!" before you post the rest of the information required to solve the problem, then wait some more for an actual answer.
|
|
|
|
|
Best guess: you're mixing types; which only works for things "typed as object".
"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
|
|
|
|
|
Oh, so we need to pass a little test before we're allowed to respond to your post? How childish.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Please help us to answer your post.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
As noted not enough information.
And the cause is based on what the exact type (resolved by the compiler) for 'subMenu[index]'
So for example from Qt docs a QWidget addAction() method takes a pointer to a QAction. And in that case a char pointer would not work. (I got that by RTFM by the way.)
|
|
|
|
|
jschell wrote: I got that by RTFM by the way Me too, but I couldn't be bothered to edit my original reply. This guy really takes the biscuit (cookie).
|
|
|
|
|
I think it's the same cookie under a different name.
"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
|
|
|
|
|
Minor add:
I think the loop increment is wrong
I have commented out inner loop and addend two more list to the array
so the decimal count should be 5.
OK the code say Array size 4
and it misses the last array.
That should be a snap to fix...
<"TASK #ifdef FUNCTION_TEST_PROJECT int MainWindow_Bluetooth::CreateMenus_Array()79"
" index array 0 Array size 4"
" index array 1 Array size 4"
" index array 2 Array size 4"
" index array 3 Array size 4"/pre>
OK, I have plain C question about nested "loop"
My task is to loop thru two dimensional array...
The error in my code is stopping the embedded loop.
Here is a snippet of the run debug messages
here is the "problem " code
for (index_main = 0; index_main < list_array[index_array][index_main].size(); ++index_main)
What am I doing wrong in sizing the array?
Many thanks for help resolving this.
Debug
<pre lang="text">" index array 0Array size 4"
" main menus 0 SubWindow terminal (QMdiArea )main menu size 34"
" main menus 1 SubWindow hcitool (QMdiArea )main menu size 34"
" main menus 2 SubWindow bluetoothctl (QMdiArea )main menu size 34"
" main menus 3 SubWindow system (QMdiArea )main menu size 34"
ASSERT failure in QList<T>::operator[]: "index out of range", file /home/nov25-1/Qt/5.15.2/gcc_64/include/QtCore/qlist.h, line 575
12:23:02: /mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/mdi/mdi crashed.
Array;
const QStringList list_array[10]
{
{ "SubWindow terminal (QMdiArea )",
"SubWindow hcitool (QMdiArea )",
"SubWindow bluetoothctl (QMdiArea )",
"SubWindow system (QMdiArea )" },
{ "SubsubWindow bluetoothctl help (QMdiArea )",
"SubsubWindow bluetoothctl list (QMdiArea )",
"SubsubWindow bluetoothctl devices (QMdiArea )",
"SubsubWindow bluetoothctl show (QMdiArea )" },
{ "SubsubWindow hcitool (QMdiArea )",
"SubsubWindow hcitool dev (QMdiArea )",
"SubsubWindow hcitool scan (QMdiArea )",
"SubsubWindow hcitool inq (QMdiArea )"}
};
Code:
for (index_array = 0; index_array < list_array[index_array].size(); ++index_array )
{
text = " index array ";
text += QString::number(index_array);
text += "Array size ";
text += QString::number(list_array[index_array].size() );
qDebug() << text;
for (index_main = 0; index_main < list_array[index_array][index_main].size(); ++index_main)
{
text = " main menus ";
text += QString::number(index_main);
text += " ";
text += list_array[index_array][index_main];
text += "main menu size ";
text += QString::number(list_array[index_array][index_main].size());
qDebug() << text;
}
}
modified 15-Jan-24 18:16pm.
|
|
|
|
|
I've never used Qt before but, this line seems odd,
for (index_array = 0; index_array < list_array[index_array].size(); ++index_array ) specifically
index_array < list_array[index_array].size() Maybe try something like
for (index_array = 0; index_array < list_array.size(); ++index_array )
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
modified 15-Jan-24 15:38pm.
|
|
|
|
|
Sorry, no go.
This is not about Qt - I no longer post questions about Qt - this is wrong forum for Qt.
This is plain C question - hence in "C..." sub forum.
In my view each loop has its stopping point.
The first - parent loop - needs to stop when it reaches the end
AND its "size" is correct (see debug message ) and I can run it bypassing the "inner " loop.
The size of inner loop is wrong - see debug messages posted.
Changing the parent loop size as suggested gets this error:
/mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth.cpp:142: error: member reference base type 'const QStringList[10]' is not a structure or union
mainwindow_Bluetooth.cpp:142:52: error: member reference base type 'const QStringList[10]' is not a structure or union
for (index_array = 0; index_array < list_array.size(); ++index_array )
~~~~~~~~~~^~~~~
|
|
|
|
|
I think you've got your logic in a twist here. I think it should be
for(index_array = 0; index_array < list_array.size(); ++index_array )
{
for(index_main = 0; index_main < list_array[index_array].size(); ++index_main )
{
}
}
Additionally, note that you're calculating list_array.size() and list_array[index_array].size() multiple times. Perhaps better would be
const size_t list_max = list_array.size();
for( index_array = 0; index_array < list_max; ++index_array )
{
const size_t array_max = list_array[index_array].size();
for(index_main = 0; index_main < array_max; ++index_main)
{
}
Maybe, since you've declared list_array as const , the compiler will be able to optimize away the unneeded function calls, but speaking for myself, I find my version just a little easier to read and understand.
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
|
|
|
|