qt

C++ static members, multiple Objects

我们两清 提交于 2021-02-11 17:22:06
问题 I've got some trouble with static members and methods in C++. This is the Class header: class Decoration { public: //Static Methods static void reloadList(); //Static Members static std::unordered_map<int, Decoration> decorationMapID; }; And in .cpp: void Decoration::reloadList() { sqlTable result = db->exec("SELECT id, name, description FROM decorations"); for(sqlRow r: result) { Decoration::decorationMapID.insert(std::pair<int,Decoration>(atoi(r[0].c_str()), Decoration(r[1], r[2], atoi(r[0]

C++ static members, multiple Objects

喜夏-厌秋 提交于 2021-02-11 17:21:32
问题 I've got some trouble with static members and methods in C++. This is the Class header: class Decoration { public: //Static Methods static void reloadList(); //Static Members static std::unordered_map<int, Decoration> decorationMapID; }; And in .cpp: void Decoration::reloadList() { sqlTable result = db->exec("SELECT id, name, description FROM decorations"); for(sqlRow r: result) { Decoration::decorationMapID.insert(std::pair<int,Decoration>(atoi(r[0].c_str()), Decoration(r[1], r[2], atoi(r[0]

Algorithm for masking time when the signal is above a threshold

让人想犯罪 __ 提交于 2021-02-11 15:37:34
问题 I have a realtime signal from a sensor. I need logic to implement a masking time once the signal is above a threshold. As shown below: Here the signal (in blue) crosses a threshold. And I need to mask for any checks for the threshold for a period (masking time). (In this way I can detect only the positive pulse , similarly, I have another check for negative pulse ) See the code below: static QTime time(QTime::currentTime()); // calculate two new data points: double key = time.elapsed()/1000.0

Algorithm for masking time when the signal is above a threshold

做~自己de王妃 提交于 2021-02-11 15:36:46
问题 I have a realtime signal from a sensor. I need logic to implement a masking time once the signal is above a threshold. As shown below: Here the signal (in blue) crosses a threshold. And I need to mask for any checks for the threshold for a period (masking time). (In this way I can detect only the positive pulse , similarly, I have another check for negative pulse ) See the code below: static QTime time(QTime::currentTime()); // calculate two new data points: double key = time.elapsed()/1000.0

Qt: How to handle custom events with connect?

半腔热情 提交于 2021-02-11 14:21:45
问题 Here is a "hello world" button that display a window and button. I would like to do a cout or any other custom functionality when the button is clicked but I'm stuck. #include <QApplication> #include <QPushButton> #include <iostream> int main(int argc, char **argv){ // create app QApplication app (argc, argv); // create window QWidget window; window.setWindowTitle("MyWindow"); window.setFixedSize(600, 480); // create button QPushButton *button = new QPushButton(&window); button->setGeometry

Virtual keyboard top black screen in Yocto

房东的猫 提交于 2021-02-11 14:00:59
问题 I am developing a device using VAR-SOM-MX7 developing in Yocto Sumo. I managed to add virtual keyboard into my QApplication but when the keyboard appeared, it overlaps the application. The textEdit field still getting the input from the virtual keyboard but just cannot show the textEdit field while typing. I have tried to: qputenv("QMLSCENE_DEVICE", QByteArray("softwarecontext")) CONFIG += disable-desktop In qml I changed the keyboard layout: keyboardBackground: Rectangle { color:

Virtual keyboard top black screen in Yocto

最后都变了- 提交于 2021-02-11 14:00:27
问题 I am developing a device using VAR-SOM-MX7 developing in Yocto Sumo. I managed to add virtual keyboard into my QApplication but when the keyboard appeared, it overlaps the application. The textEdit field still getting the input from the virtual keyboard but just cannot show the textEdit field while typing. I have tried to: qputenv("QMLSCENE_DEVICE", QByteArray("softwarecontext")) CONFIG += disable-desktop In qml I changed the keyboard layout: keyboardBackground: Rectangle { color:

Converting QImage to QByteArray using QDataStream

China☆狼群 提交于 2021-02-11 14:00:20
问题 Im trying to convert a QImage that maked from ScreenShot to a QByteArray for sending via QTCPSocket. when i convert QImage to QByteArray and before sending it i try to deserialize and show it on label it cant ! what's my mistake? thx for helping. QByteArray ImClientShooter::toQByteArray(QImage &img) { QByteArray temp; QDataStream data(&temp, QIODevice::ReadWrite); data « img; return temp; } QByteArray goOn{toQByteArray(sampleQImage)}; //sampleQImage is a QImage Object lbl->setPixmap(QPixmap:

How would I go about making a overlay widget

故事扮演 提交于 2021-02-11 13:02:49
问题 How would I go about making a overlay widget with qt? I've considered using a QPaintEvent or a QGraphicsScene, but I want to be able to add widgets and for the widget to not occupy space in a layout, causing other widgets to shift when the popup appears. 回答1: I believe the best solution is to parent the so called overlay widget to the window or even have the overlay widget be in its own window. The first solution might be easier to do, but the overlay widget is bound to the inside of the

How to detect when Text gets elided

筅森魡賤 提交于 2021-02-11 13:01:45
问题 My UI contains a Text field with horizontalAlignment: Text.AlignJustify maximumLineCount: 5 wrapMode: TextEdit.WordWrap elide: Text.ElideRight When the text does not fit, the last line should end with "... MORE" where "MORE" should be focusable. This will probably be a separate Text field where the visibility is controlled by whether or not the text is elided. But how can I detect when a Text gets elided? 回答1: When a Text gets elided, it is truncated. Here's a simple example: Text { id: