I'm in agreement with Richard on what is actually happening there. It looks like the QStringList
is being used to join all the arguments together to make a complete command line for passing to the QProcess
. /bin/sh
is the Bourne shell, you should be able to find the manual page for it online or by typing "man sh"
in your Linux terminal. I don't know why it is using a shell instead of executing the command directly, but I suspect there is a good reason. Maybe for wildcard parsing or terminal I/O buffering.
Graham Breach
Posts
-
Please - explain the C++ code / function -
Please - explain the C++ code / functionThe
<<
in this is not shift left, it isoperator<<()
operating on whateverQStringList()
returns. It might be concatenating them, or appending them to an array, or whatever. It can handle bothchar*
andQString
because it probably has overloads for both types, or possibly becauseQString
has an operator for returning achar*
. I'm guessing this from the context because the C++ standard library also uses<<
this way - you would have to consult the QT documentation to be sure. -
RegQueryValueExW vs RegQueryValueExABecause
sz
is the size of the value in bytes, not characters. If you retrieve a string from the registry usingRegQueryValueExA
you get a string with 1-byte ASCII characters, and if you useRegQueryValueExW
you get a string with 2-byte Unicode characters. -
Visual C++ 2022 cout bug?Its working fine here on Windows 10, VS 17.5.5, so I would suspect the Windows 11 terminal - can you try running it in a cmd.exe window instead?
-
How to "provide password " REMOVEDAn easier option might be to configure sudo to allow the user of your program to call it without a password. The
sudoers
file is the place to do this. Obviously there may be security implications with this, but that is up to you to decide. Another alternative is to set the set-user-id bit on your executable so that it automatically runs as root (usingchmod
andchown
). Again, this has security implications to think about. -
PHP Fatal error: Uncaught TypeError: count()Replacing
count($row[0]);
withstrlen($row[0]);
should do it. -
Passing a pointer to object - using template - followup.The part in
<>
should be a type and the compiler is complaining that it doesn't know whatdata_list
is. If it is a type, make sure you include the correct header so that it can be found. If what you actually meant was fordata_list
to be the name of the function argument, it should be more like this:explicit Form_SetupLocalAdapter(QList<*DataListType> data_list);
- replacing
DataListType
with the type (or base type) ofdata_list
. -
Basic C++ - can you explain the difference / function of each definition ?The first one creates an instance on the stack. It will be destroyed when it goes out of scope. The second one creates an instance in heap memory*. It will not be automatically destroyed and you should call
delete
to destroy it. *Unlessnew
has been overridden to do something unusual. -
Heap Storage CorruptionC doesn't have new/delete at all - you are writing C++
-
Heap Storage CorruptionYou are using
new[]
, so you must use a matchingdelete[]
:char* t = new char[70];
// do stuff with t
delete[] t;
This might not be the cause of the problem you are having, but it will cause problems.
-
Invalid comparator for STL mapI think you're making it too complicated:
struct ESDID
{
char c[4];bool operator<(const ESDID& other) const
{
return c[0] < other.c[0] && c[1] < other.c[1] &&
c[2] < other.c[2] && c[3] < other.c[3];
}
}struct usingrange
{
ESDID esdid;
int start;
int end;bool operator<(const usingrange& other) const
{
return esdid < other.esdid && start < other.start &&
end < other.end;
}
}I've used && and < because you do not want
operator<()
to return true for two different objects when you swap them around. -
Invalid comparator for STL mapDoes your ESDID class have an
operator<()
function? If not, add one. -
TSQL - JOIN cancels out my date filterYou have an
OR
in there without any parentheses, that might be the problem. Try this:AND (project.status = 'construction' OR project.status = 'finished')
Both sides of the
OR
are using the same table column, so you could useIN
insteadAND project.status IN ('construction', 'finished')
-
TSQL - Create a JOIN, knowing that it may not exist, but show the initial records at least instead of nothing [bad idea] - abandoned itNot sure if this is quite what you are looking for, but here goes:
SELECT
vendor.Vendor_ID,
vendor.Company_Name,
vendor.DELETE_FLAG,
proj_cost.cost,
proj_cost.pref_vendor
FROM vendor
LEFT OUTER JOIN proj_cost ON proj_cost.Vend_ID = vendor.Vendor_ID
WHERE (proj_cost.proj_id = '4077'
AND proj_cost.proj_stage = 'construction'
AND proj_cost.vers_id = '8'
AND proj_cost.task_Oper = '6'
AND proj_cost.vend_id = '54'
AND proj_cost.task_id = 'TK_EX_044')
-- vendor without matching proj_cost
OR proj_cost.Vend_ID IS NULL -
MFC. How to display a bitmap or a .png fileRestoring the old bitmap should happen on the
MemDCLady
DC where you called the firstSelectObject()
, not the one passed in aspDC
. -
Style questionIf the function modified the contents of the container I would probably pass it the container reference, otherwise I would prefer the iterators (or even a
std::span
). -
List assertation failureInstead of trying to manipulate the contents of these structs from outside I would add member functions to do it.
-
List assertation failureIt means that your "tcbcollecter" list was empty when you assigned the "tcbitrate" iterator. Calling
begin()
on an empty list will give you theend()
iterator, because there is no real element to point to. You can't dereference it because it doesn't point at anything. -
Help with STL list::insertWhen you want to traverse the list get an iterator with
begin()
. This is the first element in the list. Access the information you need, then increment the iterator. If it is equal toend()
then you have reached (one item past) the end of the list:for(auto i = my_list.begin(); i != my_list.end(); ++i)
{
// do something with iterator i
std::cout << "Item " << i->name << "\n";
}Or you could use range-based for:
for(auto& i : my_list)
{
// do something with i, which is a reference to the item in the list
std::cout << "Item " << i.name << "\n";
} -
Help with STL list::insertIf you want the first element of a list you can use
list.front()
and for the last elementlist.back()
. Thepush_front()
function adds elements at the start of the list andpush_back()
adds them at the end. The list doesn't start off with any fixed length, it grows and shrinks as you add and remove elements. So if I was adding two items to a list I would do something like this:ItemType item1, item2;
std::list my_list;my_list.push_back(item1);
my_list.push_back(item2);You should use
insert()
when you want to add an item in the middle of the list - the iterator you pass in should point to the element you want to insert the new item in front of.