|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
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.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
I am trying to learn using templates and run into this TWO versions of C++ code.
Both works as expected, however,....
The first version compiles , bur WON'T work until
<qaction *="">
is added to "findChildren".
Would appreciate some (REAL) comments
variation of "RTFM" not necessary.
QString textMatch = "tile";
QList<QAction*> pTEST = parent->findChildren<QAction *>();
for (auto *action : pTEST)
{
text = action->objectName();
if(text.contains(textMatch))
{
action->trigger();
text += " match ";
qDebug().noquote() << text;
break;
}
}
const auto actionList = parent->findChildren<QAction *>();
for (auto *action : actionList)
{
text = action->objectName();
if(text.contains(textMatch))
{
action->trigger();
qDebug().noquote() << text;
break;
}
}
|
|
|
|
|
1. This has nothing to do with templates.
2. If you change the word pTEST in the first example to actionList , you will see that they are both exactly the same. Barring, of course the line:
text += " match ";
which is not present in the second sample.
And since the findChildren function returns a list of QAction* items, it matters not whether you specify it explicitly, or leave the compiler to infer it from the context.
|
|
|
|
|
VOLUNTARILY REMOVED
modified yesterday.
|
|
|
|
|
|
hi all,
i am change my exe icon its working fine with icon which have single stage icon.
but if i select a icon file that have multiple size stages in icon file, icon not reflect on exe.
HANDLE handle = BeginUpdateResource(exe_file, FALSE);
char *buffer; // buffer to store raw icon data
long buffersize; // length of buffer
int hFile; // file handle
hFile = open(ico_file, O_RDONLY | O_BINARY);
if (hFile == -1)
return; // if file doesn't exist, can't be opened etc.
// calculate buffer length and load file into buffer
buffersize = filelength(hFile);
buffer = (char *)malloc(buffersize);
read(hFile, buffer, buffersize);
close(hFile);
int icon_id=1;
UpdateResource(
handle, // Handle to executable
RT_ICON, // Resource type - icon
MAKEINTRESOURCE(icon_id), // Make the id 1
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
(buffer+22),
// skip the first 22 bytes because this is the
// icon header&directory entry (if the file
// contains multiple images the directory entries
// will be larger than 22 bytes
buffersize-22 // length of buffer
);
/////////////////////
// Again, we use this structure for educational purposes.
// The icon header and directory entries can be read from
// the file.
GROUPICON grData;
icon_id=1;
// This is the header
grData.Reserved1 = 0; // reserved, must be 0
grData.ResourceType = 1; // type is 1 for icons
grData.ImageCount = 1; // number of icons in structure (1)
// This is the directory entry
grData.Width = 32; // icon width (32)
grData.Height = 32; // icon height (32)
grData.Colors = 0; // colors (256)
grData.Reserved2 = 0; // reserved, must be 0
grData.Planes = 2; // color planes
grData.BitsPerPixel = 32; // bit depth
grData.ImageSize = buffersize - 22; // size of image
grData.ResourceID = icon_id; // resource ID is 1
UpdateResource(
handle,
RT_GROUP_ICON,
MAKEINTRESOURCE(icon_id),
// MAINICON contains information about the
// application's displayed icon
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
&grData,
// Pointer to this structure
sizeof(GROUPICON)
);
delete buffer; // free memory
// Perform the update, don't discard changes
// Write changes then close it.
if (!EndUpdateResource(handle, FALSE))
{
return ;
}
please help me where i am doing mistake.
thanks in advance.
|
|
|
|
|
Le@rner wrote: buffer = (char *)malloc(buffersize);
...
delete buffer; // free memory
let's begin with the basics: Why do you use malloc to allocate buffer and then use delete to free the memory?
|
|
|
|
|
To make life more exciting?
|
|
|
|
|
Quote: (buffer+22),
// skip the first 22 bytes because this is the
// icon header&directory entry (if the file
// contains multiple images the directory entries
// will be larger than 22 bytes
buffersize-22 // length of buffer
);
The above remark is a hint, isn't it?
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
|
Thank you!
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
SOLVED
Never mind - found how to "convert " picture to text.
Is there an acceptable way to post a picture or attach a file to a post ?
I have a "debug view" I like to post.
Cheers
modified 30-Apr-24 11:57am.
|
|
|
|
|
use imgur.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
And how about copy/paste the eliable code snippet together with "debug assertion failed" message text?
|
|
|
|
|
Is here somebody ON THIS forum to help me navigate - using C++ code - thru the debug message?
and using Qt?
I am NOT going to post more just to get " do not post Qt questions here ..." ,
hence wasting my time.
|
|
|
|
|
Salvatore Terress wrote: to help me navigate - using C++ code - thru the debug message?
Please, define "navigate - using C++ code - thru the debug message".
|
|
|
|
|
Please answer FIRST
are you willing to help using Qt ?
If not
thanks
|
|
|
|
|
Salvatore Terress wrote: are you willing to help using Qt ?
If not
thanks
You are welcome!
|
|
|
|
|
Probably not since we have no idea what the problem may be. The debugger is there to help you to find the point at or near where your code has a problem. So make use of it, and when you have some proper details then post a proper question.
|
|
|
|
|
Voluntarily removed
modified yesterday.
|
|
|
|
|
This is what I understand from the above:
1. MainWindow_Bluetooth is a class that contains various properties including m_settings . When instantiated m_settings is set to point to a new SettingsDialog .
2. SD is a pointer to a new SettingsDialog . No idea where it is created or why, since this appears to be a duplicate of m_settings .
3. In the closeEvent of SettingsDialog you create some text and pass it to m_TAB_Connect , presumably to be displayed somewhere. It is not possible to say whether this is called by SD or m_settings since other parts of the code are not present.
|
|
|
|
|
UPDATE / closed - no solution found.
This was pretty futile task, there are few "private" objects I did not see until
each "parent" level was expanded.
This is an offshoot of my other post
AND
if it is NOT OK for me to continue posting - there are others who are commenting negatively
about my too many posts"
PLEASE
DO NOT REPLY
I do not want to waste "volunteers time ".
I am currently working on nested objects
main object ( patent _)
secondary object ( child )
next object ( child )
I am trying to pass correct parameters between them
I am debugging the flow using constructors and
it looks as the compiler / linker access / flow in sort of backwards
First trace is "next object " constructor ....
and then I get lost tracing....UP next object
is that normal ?
That is all I wanted to ask.
Thanks
modified yesterday.
|
|
|
|
|
I assume your question is about the order of initialization of compound objects.
#include <iostream>
using std::cout;
class level3 {
public:
level3(const std::string& name);
};
class level2 {
public:
level2(const std::string& name);
private:
level3 grandchild;
level3 favourite_grandchild;
};
class top_level {
public:
top_level(const std::string& name);
private:
level2 child;
level2 other_child;
};
top_level::top_level(const std::string& name)
: other_child("other_child") , child("child") {
cout << name << " constructor\n";
}
level2::level2(const std::string& name)
: favourite_grandchild("favourite_grandchild") , grandchild("grandchild") {
cout << name << " level2 constructor\n";
}
level3::level3(const std::string& name)
{
cout << name << " level3 constructor\n";
}
int main()
{
top_level t("top");
}
The result is this:
grandchild level3 constructor
favourite_grandchild level3 constructor
child level2 constructor
grandchild level3 constructor
favourite_grandchild level3 constructor
other_child level2 constructor
top constructor
In words: aggregate objects initialize their members in the order in which the members are declared, not in the order of initializers in the constructor of the aggregate. After initializing all members, the constructor code is run.
Mircea
|
|
|
|
|
Many thanks for helping me to analyze the problem.
I now have a better understanding what is going on and have found a part of the problem.
Here my current partial trace
19:45:53: Debugging /mnt/A_BT_DEC10/A_APR13_APR15/A_APR9_MAR7_MAR19_CLEAN/A_BT_LIBRARY/mdi/mdi ...
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
" #ifdef CONNECT START constructor A_BT_TAB_DIALOG::A_BT_TAB_DIALOG(QWidget *)"
" #ifdef CONNECT END constructor A_BT_TAB_DIALOG::A_BT_TAB_DIALOG(QWidget *)"
" #ifdef CONNECT ZTART CONSTRUCTOR SettingsDialog::SettingsDialog(QWidget *) @ line # 88"
" #ifdef CONNECT END CONSTRUCTOR SettingsDialog::SettingsDialog(QWidget *) @ line # 229"
" #ifdef CONNECT START constructor A_BT_TAB_DIALOG::A_BT_TAB_DIALOG(QWidget *)"
" #ifdef CONNECT END constructor A_BT_TAB_DIALOG::A_BT_TAB_DIALOG(QWidget *)"
" #ifdef CONNECT ZTART CONSTRUCTOR SettingsDialog::SettingsDialog(QWidget *) @ line # 88"
" #ifdef CONNECT END CONSTRUCTOR SettingsDialog::SettingsDialog(QWidget *) @ line # 229"
and it shows that both objects are "constructed " twice...
|
|
|
|