How Log Message Events by ApplicationEvents in delphi? [duplicate] - list

This question already has answers here:
Convert Windows Message IDs to Text
(3 answers)
Closed 4 years ago.
I can get events HexCode by onMessage event of applicationEvents component.
By this code:
MessagesList.Items.Add(IntToStr(MSG.message));
But I want get MessageText and add it into ListBox. For example when user pressed LeftMouseButton add "WM_LBUTTONDOWN" in ListBox.
I want List and Log All of Events handled in form.(onclick,onmousedown,onmouseup,onmousemove,....)

You have to construct your own lookup table for this. There is no built-in facility that will convert a message ID to a string representing the message's name.

Related

Resizing Checkbox in QT Creator [duplicate]

This question already has answers here:
Increase check box size not its text using QCheckbox?
(3 answers)
Closed 4 years ago.
I have created a QCheckbox in QT Creator called 'override'.
I want to change the size of the actual checkbox, not the font of the text associated with it.
Is there a way of doing this?
Thanks for the help - I used this:
eyeChk = new QCheckBox("Eyes:");
_eyeChk->setStyleSheet("QCheckBox::indicator { width:150px; height: 150px;} QCheckBox::indicator::checked {image: url(/home/jvdglind/Downloads/280px-PNG_transparency_demonstration_2.png);}");
And just found sound decent default checkbox images.

Qt connect to slot/function with args [duplicate]

This question already has answers here:
Passing an argument to a slot
(6 answers)
Closed 6 years ago.
I'm new in Qt... I'm creating N buttons based on a JSON file. And I need to run a function/slot when a button is clicked and I need to know which buttton was pressed.
I tried:
QObject::connect(button, &QToolButton::clicked, this, &base::show_brands(json, type));
show_brands(json, type) is a function/slot...
but I can't send args like this...
How can I sent args to my function/slot? Or how can I run a function when a button is clicked?
You want to use QSignalMapper;
http://doc.qt.io/qt-5/qsignalmapper.html#details
This lets you send signals from a collection of objects to a single method which can identify the source object.

Signals from delegate [duplicate]

This question already has answers here:
Passing an argument to a slot
(6 answers)
Closed 6 years ago.
I started working on a project that requires the using of the TableView. My table has 3 columns and the last column has a comboBox. Using the Delegate I managed to set the comboBox and to retrieve a signal when the index status of the comboBox changes. The problem is I can not identify from witch comboBox the signal is emited from.
If I signal to the mainWindow the QString of the comboBox this seems to be very bad. I was thinking at a solution to insert into the comboBox from each line the index of the row. Something like row + name.
I initiate the connection using the advice from another post, such like:
signals:
void boxDataChanged(const int & str);
In create editor:
QComboBox * editor = new QComboBox(parent);
editor->addItem("This");
editor->addItem("is");
editor->addItem("nice");
connect(editor, SIGNAL(currentIndexChanged(int)), this, SIGNAL(boxDataChanged(int)));
return editor;
And called like:
connect(mydelegate, &Delegate::boxDataChanged, [=](const int & str)
{
qDebug() << str;
});
This is working nice but I also need to know from witch row this is comming.
The problem is I can not identify from witch comboBox the signal is
emited from.
You can use QObject::sender to get the sender of the signal.
It will return a QObject that you can cast into the desired type.

Set Arrow Keys As Input Keys - WinForms [duplicate]

This question already has answers here:
Up, Down, Left and Right arrow keys do not trigger KeyDown event
(10 answers)
Closed 6 years ago.
I need to detect arrow keystrokes in the KeyDown event. I do understand that they need to be set as input keys but I'm not clear on how to accomplish it in C++ . Found good answers here, here and here. But that is C# and I need C++. Tried implementing like described here have this code in PreviewKeyDown but no luck.
switch (e->KeyCode)
{
case Keys::Down:
case Keys::Up:
case Keys::Right:
case Keys::Left:
case Keys::Space:
e->IsInputKey = true;
break;
}
and my KeyDown have :
if (e->KeyCode == Keys::Left)
{
///
}
Which is not working on pressing left.
What am I missing?
Here is a C++ example of how to capture Key presses:
C++ Detect when user presses arrow key
And here is the MSDN doc for the KeyDown event with some C++ code examples:
https://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown(v=vs.110).aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1
hope that helps.
I managed to solve it.
For anyone facing the same, it worked when I added events PreviewKeydown and KeyDown events with the same code, for each of the controls in the form, but not for the form.

QT How to create custom slot? [duplicate]

This question already has an answer here:
Qt, no such slot
(1 answer)
Closed 7 years ago.
I'm creating my first GUI App in QT, I'm newbie at it.
This application is supposed to count calories for me with little more options than webapps offer me.
In my program I got 4 lineedits :
lineEdit_Carbs
lineEdit_Fats
lineEdit_Protein
lineEdit_Calories
I want to do like "Realtime counter", if user provides value to any of the 3 cells, carbs,fats,proteins it shows how many calories is it already.
I tried to do this
connect(ui->lineEdit_Carbs,SIGNAL(textChanged(QString)),ui->lineEdit_Calories,SLOT(setText(CALORIE_COUNT(ui->lineEdit_Carbs->text(),ui->lineEdit_Fats->text(),ui->lineEdit_Proteins->text()))))
CALORIE_COUNT function takes 3 arguments, 3 QStrings, returns calculated QString containing the calories.
I would have to do this connection 3 times, for each lineEdit containing macronutrient.
But this seem to not work because
QObject::connect: No such slot QLineEdit::setText(CALORIE_COUNT(ui->lineEdit_Carbs->text(),ui->lineEdit_Fats->text(),ui->lineEdit_Proteins->text())) in ..\CalcProto\mainwindow.cpp:22
It says there is no such slot.
How should I create slot to make it work?
connect(ui->lineEdit_Carbs,
SIGNAL(textChanged(QString)),
this,
SLOT(intermediateSlot()));//SLOT can ignore incoming arguments
private Q_SLOTS:
intermediateSlot()
{
QString calorie = CALORIE_COUNT(ui->lineEdit_Carbs->text(),
ui->lineEdit_Fats->text(),
ui->lineEdit_Proteins->text());
ui->lineEdit.setText(calorie);// you can emit a new signal here
// carring calorie and connect it to
// ui->lineEdit, which is more Qt-ish
}
You maybe can subclass QLineEdit and reimplement the setText() method, but I am not sure you can, since it not seems to be declared as virtual
What about connecting all the QLineEdit textChanged(QString) to the the same slot and do all the work in it ?
Something like
connect(ui->lineEdit_Carbs,SIGNAL(textChanged(QString)), UpdateCalc);
connect(ui->lineEdit_Calories,SIGNAL(textChanged(QString)), UpdateCalc);
connect(ui->lineEdit_Fats,SIGNAL(textChanged(QString)), UpdateCalc);
connect(ui->lineEdit_Proteins,SIGNAL(textChanged(QString)), UpdateCalc);
where the UpdateCalc slot do all the calculations ?
Eventually you can add a timer to add a little delay to the execution so if you insert something with more than one char, you don't fire the event every time.