|
Google seems to return regular expressions to validate a mac address. Not to mention explaining forms that might be less than obvious.
mac address regular expression
Other than that the square brackets are used for character matching. Single character. Best I can tell you seem to be trying to match a sequence of characters (2 digit hex.)
|
|
|
|
|
What is a correct way to pass parameter / variable to function ?
The attached snippet writes text to the GUI object and it is done in object constructor.
My task is to pass ui->textEdit_2 to object function so it can be processed OUTSIDE constructor
ui->setupUi(this);
text = "Constructor ";
ui->textEdit_2->append(text);
text = " Initialize DEBUG trace ";
ui->textEdit_2->append(text);
private:
public:
Ui::MainWindow_C_CODE_FORM *ui;
Here is my test function declaration:
QString ShowText(QString text, QTextEdit *textEDIT );
I have tried several ways to access the function, but I am obviously "doing it wrong".
PS
I you cannot help "as is " , please, do not complain - it would work better
if you ask what is missing instead.
Thank you very much .
|
|
|
|
|
Please supply the types of your objects, a sample of how you are calling ShowText() and an explanation of why you thing you're "doing it wrong". Do you get compilation errors or warnings? Does the program crash, or do something unexpected? Does the fan in the bedroom turn on? You're not telling us, and most of us will refuse to speculate.
Keep Calm and Carry On
|
|
|
|
|
Something like
void ShowText(QString text, QTextEdit * pTextEdit)
{
pTextEdit->append(text);
} called this way:
text = "Foo";
ShowText(text, ui->text_edit2);
could work.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Thanks, I have it working calling the function within constrictor.
Appreciate your help getting this part fixed.
I am trying to call it from another part of the code and getting this error
/mnt/RAID_124/BT/BT_Oct20_BASE_/mdi/mainwindow.cpp:1274:
error: member access into incomplete type 'Ui::MainWindow_C_CODE_FORM'
mainwindow.cpp:1274:32: error: member access into incomplete type
'Ui::MainWindow_C_CODE_FORM'
ShowText(text,MWCCF->ui->textEdit());
^
../CCC_SOURCE/Bluetoothctl/../C_CODE_FORM/mainwindow_c_code_form.h:42:22: note: forward declaration of 'Ui::MainWindow_C_CODE_FORM'
namespace Ui { class MainWindow_C_CODE_FORM; }
^
I could use some help to solve this.
PS
This gives same error
ShowText(text,MWCCF->ui->textEdit);
Thanks
|
|
|
|
|
SOLVED ??
This is silly , but it works
text = " START DEBUG trace " ;
finds first QTextEdit
QTextEdit *textEditPtr = MWCCF->centralWidget()->findChild<QTextEdit *>();
or pass desired widget name (?)
QTextEdit *textEditPtr = MWCCF->centralWidget()->findChild<QTextEdit *>("textEdit");
if (textEditPtr)
{
qDebug("Found textEdit ");
textEditPtr->append(text);
}
else
qDebug() << "Did not find any QTextEdit";
|
|
|
|
|
Salvatore Terress wrote: I you cannot help "as is " , please, do not complain - it would work better Statements such as this are unnecessary, and make us suspect that you are a sock puppet for a certain member who was previously banned for abuse.
|
|
|
|
|
SOLVED
As suspected , passing parameters to object was incomplete and incorrect.
Many thanks for all support received.
modified 19-Oct-23 14:11pm.
|
|
|
|
|
It is not clear, but I suspect the compiler has optimized it to something like:
MainWindow_C_CODE_FORM *MWCCF_List = new MainWindow_C_CODE_FORM(nullptr, (QStringList){ " Process basic hcitool commands "," I/O hcitool "," DEBUG Trace " });
assuming that QSL is not used anywhere else.
|
|
|
|
|
Warning messages out of context are not very helpful. We don't know for at fact that the messages you provided to us are anything to do with the supplied code.
IMHO it seems highly unlikely that the value being optimized out is responsible for the possible memory leak. If the compiler can reason that it can optimize away a variable, it should know that no memory clean up is needed. But cleanup may be part of the the expected tasks of the programmer, and adding it in (if needed) might remove both warnings.
Start by fixing the issue you have passing the QWidget correctly. There's no telling what doing it wrong might be doing internally. It sounds like a recipe for invoking undefined behavior.
If the warnings persist after fixing the calling issue, then start by turning off optimization. If you're on Linux, you might also make sure that you're including debug symbols (-g flag). Depending on what "the tool" is, adding in debugging symbols might help narrow down the origin of the memory leak. Consult the documentation for your IDE (QT Creator?) on how you go about setting the optimization level, and turning on inclusion of debug symbols in the executable.
Keep Calm and Carry On
|
|
|
|
|
This is just an educated guess on my part, and I'm not a C/C++ expert by any means.
Maybe the compiler is telling you that it's discarding the copy of the QStringList that is being created when you pass by value.
(Especially since the value is not being used inside the function, I think the compiler might be optimising it away and letting you know.)
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I downloaded Argon2 source[^] for Java, and in it's code it's using JNA, so I also got JNA source[^]. Now the problem I have is that the JNA code also needs some DLL files, but inside the repository for JNA[^] it doesn't contain a .sln project to use that with Visual Studio and build the .dll files, but instead it has makefile, and I don't know how to use it. Can someone help me on how to build the .dll files from that repository? I need jnidispatch.dll.
For both Argon2 and JNA I choose the path using the source code and building them myself because that is what I need for the project I have, and I can't use them already compiled/jars.
C/C++ isn't something that I use as main language for any of my projects, but I can make some basic .dll files using Visual Studio for stuff that can't be made inside Java, but I never had to use makefiles, and they aren't something I was able to understand.
Even tho Java can be used on multiple OS, I only need it for Windows.
|
|
|
|
|
|
Mircea Neacsu wrote: if the DLL you need is libffi
JohnCodding wrote: I need jnidispatch.dll.
That is the DLL file I need. At least that is the first exception I get, maybe after I add that DLL I'll need another, or not, not sure.
|
|
|
|
|
|
At the bottom of the GitHub repository for JNA I found this[^]. I'll try to follow that tomorrow, maybe with that I'll get all that I need.
|
|
|
|
|
Due to all the problems in getting this to work, and also because in the project that I was going to use I'm not saving any really personal information, I'm going to stick with PBKDF2WithHmacSHA512 for password hashing.
|
|
|
|
|
I was trying to get gamma value of monitor using GetVCPFeatureAndVCPFeatureReply[^] to have the default value, and later when using SetVCPFeature[^] to be able to revert to it. But when GetVCPFeatureAndVCPFeatureReply is called, it fails. What am I doing wrong? Here is the code test:
#include <Windows.h>
#include <lowlevelmonitorconfigurationapi.h>
#include <iostream>
#include <chrono>
#include <thread>
#pragma comment(lib, "Dxva2.lib")
int main() {
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
HWND hwnd = GetForegroundWindow();
HMONITOR hMonitor = NULL;
DWORD cPhysicalMonitors;
LPPHYSICAL_MONITOR pPhysicalMonitors = NULL;
hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &cPhysicalMonitors);
if (bSuccess) {
pPhysicalMonitors = (LPPHYSICAL_MONITOR)malloc(cPhysicalMonitors * sizeof(PHYSICAL_MONITOR));
if (pPhysicalMonitors != NULL) {
bSuccess = GetPhysicalMonitorsFromHMONITOR(hMonitor, cPhysicalMonitors, pPhysicalMonitors);
if (bSuccess) {
DWORD pdwCurrentValue;
DWORD pdwMaximumValue;
bSuccess = GetVCPFeatureAndVCPFeatureReply(pPhysicalMonitors->hPhysicalMonitor, 0x72, NULL, &pdwCurrentValue, &pdwMaximumValue);
if (bSuccess) {
std::cout << "Current value: " << pdwCurrentValue << " | MaximumValue: " << pdwMaximumValue;
}
else {
std::cout << "Failed GetVCPFeatureAndVCPFeatureReply" << std::endl;
}
}
else {
std::cout << "Failed GetPhysicalMonitorsFromHMONITOR" << std::endl;
}
DestroyPhysicalMonitors(cPhysicalMonitors, pPhysicalMonitors);
free(pPhysicalMonitors);
}
else {
std::cout << "Is null" << std::endl;
}
}
else {
std::cout << "Failed GetNumberOfPhysicalMonitorsFromHMONITOR" << std::endl;
}
return 0;
}
|
|
|
|
|
On function call failure, why didn't you call GetLastError, as hinted by the documentation[^]?
Also, at the very beginning of the linked page, there is:
The physical monitor configuration functions work using the VESA Monitor Control Command Set (MCCS) standard over an I2C interface. Many monitors don't fully implement that standard; so your use of these commands might result in undefined monitor behavior. We don't recommend using these functions for arbitrary monitors without physically validating that they work as intended.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
CPallini wrote: On function call failure, why didn't you call GetLastError, as hinted by the documentation[^]?
I don't know how to use it. C/C++ isn't my main language, and only use it when I have to.
CPallini wrote: Also, at the very beginning of the linked page, there is:
That is not a problem for my monitor.
|
|
|
|
|
|
I'm going to look for other ways to change gamma and brightness as this function has too many limitations on hardware. In the past I used SetDeviceGammaRamp[^] for changing gamma, but now it seems that function shouldn't be used anymore.
If anyone has some suggestion, they are welcomed and helpful.
|
|
|
|
|
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gfx.hpp>
using namespace gfx;
template <typename Source>
void print_ascii(const Source& src) {
static const char* col_table = " .,-~;+=x!1%$O@#";
for (int y = 0; y < src.dimensions().height; ++y) {
for (int x = 0; x < src.dimensions().width; ++x) {
typename Source::pixel_type px;
src.point(point16(x, y), &px);
const auto px2 = convert<typename Source::pixel_type, gsc_pixel<4>>(px);
size_t i = px2.template channel<channel_name::L>();
putchar(col_table[i]);
}
putchar('\r'); putchar('\n');
}
}
int main(int argc, char** argv) {
if(argc>1) { float scale = 1; if(argc>2) { int pct = atoi(argv[2]);
if(pct>0 && pct<1000) {
scale = ((float)pct/100.0f);
}
}
file_stream fs(argv[1]);
svg_doc doc;
svg_doc::read(&fs,&doc);
fs.close();
auto bmp = create_bitmap<gsc_pixel<4>>(
{uint16_t(doc.dimensions().width*scale),
uint16_t(doc.dimensions().height*scale)});
if (bmp.begin()) {
bmp.clear(bmp.bounds());
draw::svg(bmp,bmp.bounds(),doc,scale);
print_ascii(bmp);
free(bmp.begin());
}
}
return (argc<1);
}
And there's this documentation[^]
I was wondering how difficult it is to follow. I'm most interested in terms of what it looks like to use my graphics library as above. Is it confusing? intuitive? I've had precious little feedback on it.
Note that I am not using the STL for things like iostream because this is primarily IoT and embedded, and the STL is limited on some of my targets.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Even "lower case" comments without punctuation are "jarring" for some people. One can never be too well dressed; especially when out in public.
"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
|
|
|
|
|
Ha! What's jarring to me is
When people write partial sentences. - punctuating and capitalizing them as though they are complete sentences.
Comments to me are usually partial thoughts rather than complete sentences like
if(ptr) { // if not out of mem
memcpy(buf,ptr,sizeof(buf)); // copy it
}
Like that, so that's why I do not punctuate
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|