@Christian-Ehrlicher
@J-Hilk said in Wrong enum value from QSettings using Qt 6:
@Cobra91151 did you also use Q_ENUM_NS or Q_ENUM if your declaration is inside a QObject class?
cough 🤓
might be in it since the beginning of Qt6 ? because I don't remember it ever working without the Q_ENUM macro?
@JoeCFD
I meant for example all the sample code etc. I have seen out there for Qt5 is for qmake and .pro files. And the OP seems to be getting into some difficulty. But you know more than I in this area.
@Aviral-0 said in Errors in EventLogger. This eventlogger is designed on Qt5 but having these errors in QT 6.2:
if (this->screenshotsEnabled && eventType.compare("MouseMove") != 0)
{
QPixmap *gb;
gb mainWidget->grab().toImage().save(screenshotDirName + "/" + QString::number(elapsedTime) + ".png", "PNG");
}
Its showing error, Please Help!
As @SGaist points out, you are missing a "=".
You are also not initialising your pointer (a C++ cardinal sin) but ultimately that's a moot point.
QWidget::grab() returns an actual QPixmap, not a pointer to one.
There is also no need to convert the QPixmap to a QImage in order to save it: QPixmap::save().
if (this->screenshotsEnabled && eventType.compare("MouseMove") != 0)
{
QPixmap gb = mainWidget->grab();
gb.save(screenshotDirName + "/" + QString::number(elapsedTime) + ".png", "PNG");\
// Consider whether you need to check that the save was successful
}
Thanks for sharing!
Regarding 1) and 2) - git is my preference.
(Comes with a handy advantage: When you find a way to make Qt even better, you can just push it ;-)
@SGaist I changed the desing: Now QPushButtons are displayed in the QScrollArea, so the Button with the ssid and the other elements (The line to write a password, the button to connect to a network) are shown separately. With these simple changes, the code I wrote before works like a charm! True, It wasn't what I originally intended, but I realized that it's far better due to the circumstances where this app is going to be used.
Thanks for your time and your help!
@JeniaR said in QTimer understanding:
That thread does some working and that's why it's required as a separate thread
This still does not answer why a QTimer in this thread emits a signal which is handled in the main thread - this makes no sense.
You can compile them separately, i.e. you select the desktop kit and compile the desktop project, then select the mcu kit and compile the mcu project. However, I am not aware of a way to compile both in one go at the same time. This is not necessarily a restriction from Qt (or rather Qt Creator in this case), but from CMake. You need to teach your CMake project to use two different compilers for different (sub-)projects. I can't help you with this, though.
@J-Hilk said in Parsing a hexadecimal data and calculating checksum:
I think the OP's question is: "How do I take only 4 Bytes from my QByteArray, so that I can convert it into an int32?"
@jsulm nope, it just exists when the size doesn't match
So if you want to access 4 bytes (sizeof(int32)) for conversion use QByteArray QByteArray::mid(qsizetype pos, qsizetype len = -1) const. Otherwise if you want it to appear as an array of int32 (and you know byte ordering is correct) use reinterpret_cast<> to int array on the data.
@chunxu
Yes, cmake (default at Qt6) is quite different from qmake (default at Qt5), your project would need to be reconfigured if changing between the two.
Ensure you build a debug version of your project:
then run the program in the debugger:
generate the crash:
then look at the debugger panes at the bottom of your screen. The left panel is the back trace (yours will be longer). Right-click to copy the text:
Select the top-most line in the back trace that is in your code. There is a panel that shows the variables in scope at the time of the call selected.
@Rumeysa_135 I gave you a link to a method to convert a hex string to an integer and @Emre-MUTLU gave you code to split a string into hex numbers. You should now be good to go and write what you need. If something is not clear then please ask concrete questions and provide more details.
Hi,
From old memories, I usually did not reload settings from constructors.
I would build the whole UI and then trigger the settings loading using a 0 based single shot QTimer.
That said, I am wondering whether there's a system cache doing something in between. I remember macOS having some funny behavior in that regard.
@inusion said in Qt mcu project can't include libraries like QCanBus, QObject?:
@JKSH
Thank you for answer.
I'm trying to do can communication using nxp, but will it work in nxp even if I use the RSCANFD library?
You're welcome.
RSCANFD is for Renesas MCUs. Please ask your supplier which C/C++ CAN library can be used with your NXP MCU.
QPixmap pixmap(QPixmap::fromImage(QImage(img.data, img.cols, img.rows, img.step, QImage::Format_RGB888)).copy());
if this does not work than your incoming image data is not correct. You can easily look what's inside the QImage by saving it to a file.
@sierdzio yes, that seemed to fix it.
Item {
id: banner
property int bannerHeight: 80
implicitHeight: (opMode.mode === OpModes.Service) || (navBar.tabIndex === 3) ? bannerHeight : 0
Behavior on implicitHeight {
NumberAnimation { duration: 250 }
}
Layout.fillWidth: true
Rectangle {
id: rect
anchors {
left: parent.left
right: parent.right
}
implicitHeight: parent.implicitHeight
...
}
}
I think I need to apply a similar animation to the opacity of the contents of the Rectangle (a couple lines of text and a Button), but I get the principle now.
Thanks to all for the help.
@JKSH said in A problem that has been bothering me for 7 months:
This was in your error log.
To fix it, install the Qt Positioning module.
Following this, I fix it! Thanks
Hi,
Determine on enter whether further processing shall be done.
And for the move, your entire widget might not be a target for dropping or might change the outcome based on some condition.
@Captain-Haddock said in Hiding/unhiding parent dialogs affects mouse handling:
I tried this and the hide/unhide works but a side effect appears to be that a mouse release handler on the window subsequently fails to trigger
MouseRelease in what class?
Side-note: Your "window" only gets the event, if no other child widget consumes it. Any mouseRelease on child widgets of your window doesnt trigger Window::mouseReleaseEvent.
Events are propagated up the object tree until one widget takes it.
@judethedude said in How to draw row selection if item delegate has been subclassed:
(courtesy of chatGPT actually)
OOI, do you know exactly how you phrased your question to ChatGPT?
@Axel-Spoerl Thanks for the answer, other windows do not jittering at all, even the similar code is implemented on QML, I just wanted to make sure that I am doing everything correctly in terms of programming on Qt.
Thank you.
@JonB So it seems the only way is to firstly add the widget to desktop, then manage its native handle to be transient for the parent window from the host.
QML is loaded before the signal is called but you are close on the DataProcess instances. I found the issue last night. I have a QML module that is called when a menu item or button is clicked to start the data import and this module calls the C++ function. I had been trying to get my head around the setContextProperty vs qqmlRegisterType debates and made changes so I used setContextProperty and then used that name in the QML modules. I changed main.qml but never thought about the getdata QML modulel - I mean it just calls the function, right <G>! I used the setContextProperty name in the get data module and it all works now.
Thanks for answering.
@sierdzio said in Slot not invoked when sending signal with enum values:
You mean the JS function is the slot
yes.
I doubt something like this will work at all
I think it can, but it's highly discourage to do it this way. Can't remember the reason.
I'll try to look it up. https://doc.qt.io/qt-6/qtqml-cppintegration-interactqmlfromcpp.html#accessing-loaded-qml-objects-by-object-name
accidentally found the issue of the op:
function onBatterySoC(BTSoC)
BTSoC is of type var -> the c++ signal argument must be of type QVariant
https://doc.qt.io/qt-6/qtqml-cppintegration-interactqmlfromcpp.html#invoking-qml-methods
@learn_Qt
Assuming you wish to make individual columns look different from one another. Override the QAbstractItemModel::data() and/or QAbstractItemModel::headerData() methods in your derived model class to produce varying appearance roles on a per column basis. Potentially see also QHeaderView or QStyledItemDelegate depending on your requirements.
@KenAppleby-0 said in No Console Output To Terminal on Windows When Using CMake:
So the answer seems to be to not have either WIN32 in the add_executable or WIN32_EXECUTABLE ON in the set_target_properties?
Yes - as the documentation states WIN32 creates an application with WinMain() as entry point and therefore has no console.
@AnneRanch said:
how do I DELETE the TEST menu ?
Right click on it in the object tree and select "Remove".
I want to delete "menuBluetooth and start over
Same. Right click on it in the object tree and select "Remove".
That's how you delete menus. To delete an action right click on it in the actions window and select "Delete" (a bit of option naming inconsistency but whatever).
add new menu "Bluuetooth" .
All I am getting is "TYPE here " and no way to say "save it " .
Double click on "Type Here", type the text you want to see and hit enter. If you do that on a menu bar it will add a menu. If you do that inside a menu it will add an action.
There is no obvious "drag and drop" ...
Drag & drop is for existing actions. They are listed in the actions window. You dag it from there and drop it in the preview window of your form onto the menu you want to put it in.
If you want to create a new action that's not yet on the list you can use the "Type Here" method mentioned above. That will create a new action and add it to the menu. Alternatively you can create an action by clicking the "New" icon on the toolbar of the actions window and then drag&drop it onto a menu.