qt5

How to store a QPixmap in JSON, via QByteArray?

空扰寡人 提交于 2020-07-29 05:44:08
问题 I have a QByteArray , which I want to save in a JSON file using Qt and also be able to read from it again. Since JSON natively can't store raw data, I think the best way would probably be a string? The goal is to save a QPixmap this way: { "format" : "jpg", "data" : "...jibberish..." } How do I achieve this and how do I read from this JSON Object again (I am using Qt5)? What I have right now looks this way: QPixmap p; ... QByteArray ba; QBuffer buffer(&ba); buffer.open(QIODevice::WriteOnly);

How to store a QPixmap in JSON, via QByteArray?

[亡魂溺海] 提交于 2020-07-29 05:43:34
问题 I have a QByteArray , which I want to save in a JSON file using Qt and also be able to read from it again. Since JSON natively can't store raw data, I think the best way would probably be a string? The goal is to save a QPixmap this way: { "format" : "jpg", "data" : "...jibberish..." } How do I achieve this and how do I read from this JSON Object again (I am using Qt5)? What I have right now looks this way: QPixmap p; ... QByteArray ba; QBuffer buffer(&ba); buffer.open(QIODevice::WriteOnly);

How to store a QPixmap in JSON, via QByteArray?

喜夏-厌秋 提交于 2020-07-29 05:43:00
问题 I have a QByteArray , which I want to save in a JSON file using Qt and also be able to read from it again. Since JSON natively can't store raw data, I think the best way would probably be a string? The goal is to save a QPixmap this way: { "format" : "jpg", "data" : "...jibberish..." } How do I achieve this and how do I read from this JSON Object again (I am using Qt5)? What I have right now looks this way: QPixmap p; ... QByteArray ba; QBuffer buffer(&ba); buffer.open(QIODevice::WriteOnly);

Configure Qt Creator for Android development

早过忘川 提交于 2020-07-22 21:19:20
问题 I have installed: Qt 5.14.1 for msvc 2017 & Android installed to c:\Qt\Qt5.14.1\ : Compilers available in Qt Creator: Kits available: JDK-13.0.2 installed to c:\Program Files\Java\jdk-13.0.2 Android Studio 3.6.1 g:\Android\Android Studio\ with SDKs installed to g:\Android\SDK as shown below: SDK tools: Now what I see in Qt Creator: How can I fix these errors? Why did they arise? Edit: I've installed JDK 8 instead of 13. But still have the same red crosses. Also in the topic 'Platform SDK

QML - Cannot assign to non-existent property “style”

独自空忆成欢 提交于 2020-07-18 09:07:54
问题 I'm using Qt 5.10.1 with Qt Creator 4.5.1 and the style property is never available in elements. For example, as shown here ButtonStyle QML Type , I would like to do: Button { text: "A button" style: ButtonStyle {...} } But, I get the error: Cannot assign to non-existent property "style" I tried with a rectangle, progressbar and I get the same error. Edit #1: I do have all these imports. If the import was missing, I would get the error on ButtonStyle , but the error is on style . import

how to position the QIcon in the Qt table item?

≯℡__Kan透↙ 提交于 2020-07-16 04:41:25
问题 I want a table cell with text aligned to the left and icon aligned to the right side. But now, im getting both icon and text left aligned, here what i have tried QtTableWidgetItem * item = new QtTableWidgetItem("program"); item -> setIcon(icon); ui -> tableWidget -> setItem(i,j,item); 回答1: To manage the position of the icon and the text you must use a delegate, in this case I use the QStyledItemDelegate and I overwrite the initStyleOption() method: C++ version aligndelegate.h #ifndef

how to position the QIcon in the Qt table item?

穿精又带淫゛_ 提交于 2020-07-16 04:41:07
问题 I want a table cell with text aligned to the left and icon aligned to the right side. But now, im getting both icon and text left aligned, here what i have tried QtTableWidgetItem * item = new QtTableWidgetItem("program"); item -> setIcon(icon); ui -> tableWidget -> setItem(i,j,item); 回答1: To manage the position of the icon and the text you must use a delegate, in this case I use the QStyledItemDelegate and I overwrite the initStyleOption() method: C++ version aligndelegate.h #ifndef

QML crash in Qt 5.9 - help to read stack trace

心已入冬 提交于 2020-07-15 08:17:22
问题 I am writing an app using Qt 5.9 with C++ main and QML UI on the top. Everything fine (including sending signals from C++ to QML) but when I add ChartView to the UI, I am seeing a crash. The stripped-down version of the ChartView looks like the following; when I omit it from the code, no crash. ChartView { id: _chartView LineSeries { name: "avgZ" XYPoint { x: 0; y: 0} } } This is the stack trace (via excellent backward-cpp): Stack trace (most recent call last): #27 Object "", at

How to set background color of QComboBox button?

て烟熏妆下的殇ゞ 提交于 2020-07-09 10:51:13
问题 Version/Environment: Windows 10 64 bit Qt 5.11.0 MSVC2017 64 bit I have a simple QComboBox to enable/disable a feature: QComboBox *onOffComboBox = new QComboBox(); onOffComboBox->insertItem(0, "Off"); onOffComboBox->insertItem(1, "On"); The combo box is added as a cell widget to a table: this->ui->settingsTable->setCellWidget(rowNumber, 1, onOffComboBox); Now i want to change the background color of the button but not the select items. My first approach was simply to use QWidget 's

How to set background color of QComboBox button?

元气小坏坏 提交于 2020-07-09 10:46:23
问题 Version/Environment: Windows 10 64 bit Qt 5.11.0 MSVC2017 64 bit I have a simple QComboBox to enable/disable a feature: QComboBox *onOffComboBox = new QComboBox(); onOffComboBox->insertItem(0, "Off"); onOffComboBox->insertItem(1, "On"); The combo box is added as a cell widget to a table: this->ui->settingsTable->setCellWidget(rowNumber, 1, onOffComboBox); Now i want to change the background color of the button but not the select items. My first approach was simply to use QWidget 's