|
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<int>::size_type
To
std::vector<int>::size_type size
See if any errors go away.
modified 2-Feb-24 14:34pm.
|
|
|
|
|
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".
|
|
|
|
|
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();
obj.connect(&subMenu[index],&QMenu::triggered,&subMenu[index],[](QAction* action)
{
}
);
#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 )
|
|
|
|
|
You are getting somewhere. Try this:
QObject obj;
Salvatore Terress wrote: (I do not like lambda - too cryptic ) Tough!
Mircea
|
|
|
|
|
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
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
|
|
|
|
|
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...
|
|
|
|
|
hi,
VS=2015
in my mfc dialog class that is inherited from CDialogEx, i can find PreTranslateMessage method?.
I select the myDlg class, and there is no such method. Need it for some char exclusions inside edit box.
There is no Onchar method for edit box either.
|
|
|
|
|
Open ClassWizard and and add virtual method PreTranslateMessage.
Then select the message WM_CHAR to handle it in OnChar
|
|
|
|
|
How to? I know the basic printing functions and using the CPrintDialog plus PRINTDLG pd,
a little sample that only prints a statement but shows what I am using:
CPrintDialog dlg(FALSE, pd.Flags);
if (dlg.DoModal() != IDOK)
{
AfxMessageBox("Abort or Unknown Printer or Printer device error");
return;
}
pd.hDC = dlg.CreatePrinterDC();
ASSERT(pd.hDC !=0);
CDC * dc = new CDC;
dc = CDC::FromHandle(pd.hDC);
int cxPage = ::GetDeviceCaps (pd.hDC, HORZRES) ;
int cyPage = ::GetDeviceCaps (pd.hDC, VERTRES) ;
sizePrn.cx = cxPage;
sizePrn.cy = cyPage;
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -MulDiv(12, dc->GetDeviceCaps(LOGPIXELSY), 72);
lf.lfWeight = FW_BOLD;
lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
lf.lfQuality = PROOF_QUALITY;
lstrcpy(lf.lfFaceName, "Times New Roman");
VERIFY(font.CreateFontIndirect(&lf));
dc->SetMapMode (MM_ISOTROPIC) ;
dc->SetWindowExt ( 1000, 1000) ;
dc->SetViewportExt (cxPage / 2, -cyPage / 2) ;
dc->SetViewportOrg (cxPage / 2, cyPage / 2) ;
dc->SetTextAlign(TA_BASELINE | TA_CENTER);
dc->SetBkMode(OPAQUE);
dc->SetMapMode(MM_TEXT);
dc->PatBlt(0, 0, sizePrn.cx, sizePrn.cy, WHITENESS);
dc->LPtoDP(&sizePrn);
dc->SelectObject(&font) ;
CSize extentChar = dc ->GetTextExtent("M",1);
int nCharHeight = extentChar.cy+4;
int nCharWidth = extentChar.cx+10;
BeginWaitCursor();
CString printDate = GetMyCurDateTime();
DOCINFO docinfo;
memset(&docinfo, 0, sizeof(docinfo));
docinfo.cbSize = sizeof(docinfo);
docinfo.lpszDocName = _T("Calif Lottery Winnings");
docinfo.fwType = 0;
rc = dc->StartDocA(&docinfo);
if (rc < 0)
{
sprintf(temp, "Unable to Begin printing - Error[%d]", rc);
MessageBox(temp, NULL, MB_OK);
dc->ReleaseAttribDC();
dc->ReleaseOutputDC();
dc->DeleteTempMap();
EndWaitCursor();
DeleteDC(pd.hDC);
if(pd.hDevMode != NULL)
GlobalFree(pd.hDevMode);
if(pd.hDevNames != NULL)
GlobalFree(pd.hDevNames);
dc = 0;
return;
}
szTitle=CString("California Lottery System Printout ") + printDate;
dc -> StartPage();
dc -> SetTextAlign(TA_LEFT | TA_TOP);
dc -> TextOut(0, 0, szTitle, szTitle.GetLength() );
dc -> MoveTo( 0, nCharHeight );
dc -> LineTo(dc -> GetTextExtent(szTitle, szTitle.GetLength()).cx, nCharHeight);
nStart =1;
And goes on to print 1 page.
What I want to do is to place a non-character on a ticket but not like an 'X' but a block like a pencil fill-in mark at a specific place on the paper. I need to supply the coordinates for the mark and do that for the full page. Has anybody done something like this before? if so, give me some hints.
Thanks
Craig
|
|
|
|
|
When things get too complicate (re: printing), I create "forms" / pages / windows that match the required output; then "capture" the visual and print that in one go (as an "image" or whatever). Total WYSIWYG. Users can even "update" the "report" (if you let them).
"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
|
|
|
|
|
That is a good idea, will look into it.
|
|
|
|
|
I am debugging / modifying my working loop code and like to insert test code and "skip " the rest of large loop.
What would be a cool way to accomplish that...?
I have been "commenting out " temporary unwanted code , but that is pretty clumsy when large code blocks are commented out.
for (index = 0; index < list.size(); ++index)
{
... working code
{
...insert test block
}
... skip this working code
} loop end
|
|
|
|
|
If I find I need to do something like this I do something like
#ifdef DEBUG
void foo( ... )
{
}
#endif
In debug mode, then I can call foo(arg, arg, arg, ... ) when I need to. Usually this would do something like print all the elements of a collection, for example.
As far as I know, you can't skip over code. You can set a break point at the top of the loop, and continue to that point. If you really want to omit portions of the loop in your debug testing the best I could suggest would be to wrap that in an #ifdef DEBUG/#endif. Alternatively, you might
#if DEBUG == 2
...
#endif Of course, you could use #if DEBUG <= 2 , etc to get different debug levels of code when you compile.
If you go that route, check with your IDE. It probably does not add a -DDEBUG to the compile command line in debug mode, so you'd have to do that yourself. If you want to have different debug levels you would pass -DDEBUG=2 (e.g.) (Linux - its probably different, but similar for windows)
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
modified 28-Jan-24 15:44pm.
|
|
|
|
|
Do you mean this (skip to next iteration)
for (int n=0; n<10; ++n)
{
cout << "working code A\n";
{
cout << "debug code, iteration = " << n << "\n";
continue;
}
cout << "working code B\n";
}
Or, possibly, this (skip the loop)
for (int n=0; n<10; ++n)
{
cout << "working code A\n";
{
cout << "debug code, iteration = " << n << "\n";
n=10; continue;
}
cout << "working code B\n";
}
?
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
In C++
Macros
- As noted you can remove the code entirely
- You can also use a macro that resolves to a different value
For code
- Add a flag.
- Add a class that manages flags
Larger apps would use the second.
Your code then tests the flag. There are various ways the flags can be set: command line, config file, database. There are various ways to manage the class itself. Could be static or use a builder pattern.
Example of flag usage
if (myFlagClass.IsSet("TestFlag131")) ....
For systems (not just an app) can use special values in an API. The code of the target service looks for those special values and returns a fixed, or even variable, result. This is somewhat useful in verifying end to end enterprise functionality.
|
|
|
|
|
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
|
|
|
|
|