qt5

How to convert Q_ENUM to QString for QT > 5.11 most efficient way?

不问归期 提交于 2021-02-05 08:51:35
问题 I read several advices how to get an actual QString from a Q_ENUM value. Below are 3 possible ways, I came up with, that are compilable constructs in QT5.11.1 What of them should one prefer and why? void MainWindow::setErrorText(QCanBusDevice::CanBusError error) { QString errorString; QDebug(&errorString) << error; ui->statusBar->showMessage("Error occured: " + errorString); // QT4 ? const QMetaObject& mo = QCanBusDevice::staticMetaObject; QMetaEnum me = mo.enumerator(mo.indexOfEnumerator(

collect2.exe: error: ld returned 5 exit status

十年热恋 提交于 2021-02-04 22:17:31
问题 I've recently updated all msys2 packages and now I can't build my project. The error occurs at the moment of linking one of .dlls - target_library.dll . The error message isn't clear to me. What does status 5 mean? collect2.exe: error: ld returned 5 exit status Full message: g++ -Wl,-s,--relax,--gc-sections -shared -Wl,-subsystem,windows -mthreads -Wl,--out-implib,C:/msys64/workspace/Project_Root_Directory/project/src/../build/release/plugins/libtarget_library.dll.a -o ../../../../build

collect2.exe: error: ld returned 5 exit status

佐手、 提交于 2021-02-04 22:13:20
问题 I've recently updated all msys2 packages and now I can't build my project. The error occurs at the moment of linking one of .dlls - target_library.dll . The error message isn't clear to me. What does status 5 mean? collect2.exe: error: ld returned 5 exit status Full message: g++ -Wl,-s,--relax,--gc-sections -shared -Wl,-subsystem,windows -mthreads -Wl,--out-implib,C:/msys64/workspace/Project_Root_Directory/project/src/../build/release/plugins/libtarget_library.dll.a -o ../../../../build

Converting QString to Ascii value & Vice Versa in Qt

回眸只為那壹抹淺笑 提交于 2021-02-04 15:52:25
问题 I have a QString StrData = "abcd" and I want get the Ascii value in hex of that string and Vice Versa. For example from "abcd" to "61 62 63 64" and from "61 62 63 64" to "abcd" I manage to get the Ascii value in hex but don't know how to get it back Qstring StrData = "abcd"; Qstring HexStrData; for (int i = 0; i < StrData.length(); i++) { HexStrData.append(Qstring::number(StrData.at(i).unicode(), 16)); HexStrData.append(" "); } 回答1: To do the first conversion you can use the following method:

qspinbox64 in QT5.15.2

北慕城南 提交于 2021-01-29 20:34:07
问题 I tried to create a qspinbox64 as suggested in 64bit int Spin Box in QT qspinbox64.h #define QSPINBOX64_H #include <QtGui> #include <QtWidgets> namespace Ui { class QSpinBox64; } class QSpinBox64Private; class Q_WIDGETS_EXPORT QSpinBox64 : public QAbstractSpinBox//QSpinBox { Q_OBJECT Q_PROPERTY(int64_t minimum READ minimum WRITE setMinimum) Q_PROPERTY(int64_t maximum READ maximum WRITE setMaximum) Q_PROPERTY(int64_t value READ value WRITE setValue NOTIFY valueChanged USER true) int64_t m

QSqlTableModel displays images from SQL query saved as blob

假装没事ソ 提交于 2021-01-29 10:33:42
问题 I am trying to display a products type table with product name price and image using QSqlTableModel, but can't figure out how to do it. QSqlQueryModel *model = new QSqlTableModel(); model->setQuery(query); ui->produit_table->setModel(model); table preview: 来源: https://stackoverflow.com/questions/65612312/qsqltablemodel-displays-images-from-sql-query-saved-as-blob

Could not load Spatialite extension in qSqlite ( QT 5.9)

三世轮回 提交于 2021-01-29 10:05:49
问题 I am trying to load Spatialite as extension in qSqlite ( Qt 5.9), I have done that before with Qt4.8, but I failed with the QT5.9. I changed the sqlite.pri by removing "SQLITE_OMIT_LOAD_EXTENSION", and I did some change on the sqlite.c by removing the " #define SQLITE_OMIT_LOAD_EXTENSION 1 ", and adding " #define SQLITE_ENABLE_LOAD_EXTENSION 1 ". I also add the following lines to openDatabase(....) #if defined(SQLITE_ENABLE_LOAD_EXTENSION) | SQLITE_LoadExtension|SQLITE_LoadExtFunc #endif Now

Qt: How can I align widgets in two different QGridLayouts?

偶尔善良 提交于 2021-01-29 09:30:21
问题 I am trying to line up widgets from two different QGridLayouts. The idea is the following: I have many rows of widgets in the QGridLayout of a scroll frame. Each row contains maybe 8 columns of other widgets (so a grid of 8xN widgets, N = # of rows). The first widget in that row is a show/hide button that when checked, will show another widget with the same layout just below that row (i.e. that shown widget has rows of widgets, each row has 7 columns of widgets). So the shown widget will be

How to split QTextEdit into pages?

≯℡__Kan透↙ 提交于 2021-01-29 09:24:53
问题 I'm using QTextEdit from C++ Qt5. I want to properly split and show rich text in numerated pages similarly to how it's done in Microsoft Word. I've tried document->setPageSize , however that does not work for me - text is still shown in one continuous page. 回答1: AFAIK QTextEdit doesn't support the word-processor-style concept of "pages". Rather, QTextEdit is designed around editing and viewing a continuous document, whose only delineation is at the level of "blocks" (i.e. paragraphs). Note

How do I stop a custom widget from expanding in PyQt5?

孤者浪人 提交于 2021-01-29 08:35:53
问题 I'm trying to make a widget which contains many other widgets and I keep having problems with resizing the window: the widget keeps expanding even if I "tell" it not to. Here is my minimal example: from PyQt5 import QtWidgets, QtGui, QtCore class CustomWidget(QtWidgets.QWidget): def __init__(self): super().__init__() self.layout = QtWidgets.QGridLayout() self.button1 = QtWidgets.QPushButton("Button A") self.button2 = QtWidgets.QPushButton("Button B") self.label1 = QtWidgets.QLabel("Long label