qt5

How to mock a QML component

陌路散爱 提交于 2019-12-23 08:46:50
问题 Actually I'm trying to run some test on a QML component which embeds C++ objects. Unfortunately, I'm getting some errors when I execute my tests. The C++ objects aren't recognized by the QML file. That makes also sense as the C++ objects are set in the main.cpp file. My question is: How can I mock an context property for performing QML tests? Or other said, how can I do unit-test with mixing Qt/QML code? 回答1: As I understand you right, you got same problem as I. Some time ago I wrote this

QWinTaskbarProgress won't show

大憨熊 提交于 2019-12-23 07:49:04
问题 I'm using windows7 and Qt5.3.0 I added below to my MainWindow's constructor but nothing shows on my taskbar. Did I miss something? QWinTaskbarProgress * pTaskbarProgress = new QWinTaskbarProgress(this); pTaskbarProgress->setMinimum(0); pTaskbarProgress->setMaximum(100); pTaskbarProgress->setValue(50); pTaskbarProgress->show(); 回答1: See the example in the documentation: QWinTaskbarButton *button = new QWinTaskbarButton(widget); button->setWindow(widget->windowHandle()); button->setOverlayIcon

Segmentation fault (core dumped) in Qt5 application

一笑奈何 提交于 2019-12-23 05:59:37
问题 I have a Qt5 application that runs fine in the qtcreator, but if I try to run in by the executable created through terminal I get Segmentation fault (core dumped) I've tried in debug mode in Qt but no errors. 回答1: If a program crashes when run outside of a debugger, but doesn't crash when run inside the debugger, it might be a sign that you are using uninitialized data. More specifically, an uninitialized pointer. Debuggers generally clears all data, including local variables. That means that

Application doesnot launch created using MSVC2010

自作多情 提交于 2019-12-23 05:47:15
问题 I have created a exe using qt 5.0.2. Application launches if I try o launch it using qt creator. However application fail to launch which is created using MSVC 2010 pro edition. When I double click on exe it will comes out and it will not display any error or dll missing errors. Is there any way to fix/debug these kind of issues. 来源: https://stackoverflow.com/questions/17058342/application-doesnot-launch-created-using-msvc2010

Set pixel value of 16 bit grayscale QImage

蹲街弑〆低调 提交于 2019-12-23 04:56:43
问题 I have an 16 bit image of width ("imagewidth") and height ("imageheight"). The data is currently stored in an unsigned short int array of length ("imagewidth"*"imageheight") I want to create an 16 bit grayscale QImage (using Qt 5.14) from my dataset which is called "data". This is the code that I am using: QImage image = Qimage(imagewidth,imageheight,QImage::Format_Grayscale16); for(int i=0;i<imagewidth;i++) { for(int j=0;j<imageheight;j++) { uint pixelval = data[i+j*imagewidth]; QRgb color =

qsTrId and .arg(): how to use it?

陌路散爱 提交于 2019-12-23 03:10:00
问题 for a project I'm forced to use qsTrId for i18n and I'm now in need of arguments in the string. Sadly, the documentation for the command does not help about. I've this sample code: Text { id: someId //% "%1 my translatable suffix!" text: qsTrId("my_translatable_id_with_argument").arg("This is") } It will output the following error: QString::arg: Argument missing: my_translatable_id_with_argument, This is The documentation for arg say it need to work with strings, so I fear that the my

“module QtQuick is not installed” error in Release build with windeployqt

一世执手 提交于 2019-12-23 03:08:09
问题 I have a simple Qt 5.11 x64 project, MSVC 2017 compiler, with default build settings created by Qt Creator 4.7. It works fine but when I added windeployqt for copying all Qt dlls in Release build I get error (running from Qt Creator) QQmlApplicationEngine failed to load component qrc:/qml/main.qml:1 module "QtQuick" is not installed QML file has import QtQuick 2.7 .pro QT += quick widgets xml CONFIG += c++11 CONFIG += precompile_header PRECOMPILED_HEADER = stdafx.h CONFIG -= embed_manifest

QTableView with multiline cell

喜欢而已 提交于 2019-12-23 02:56:13
问题 How can I create a QTableView multiline cell? I'm filling the table using the code bellow. But Whem GetDescription() returns a long string, the content is terminated with ... There is some way to automatic break the line? QStandardItemModel * model = new QStandardItemModel(logos.size(), 2, this); model->setHorizontalHeaderItem(0, new QStandardItem(QString(""))); model->setHorizontalHeaderItem(1, new QStandardItem(QString("Nome"))); model->setHorizontalHeaderItem(2, new QStandardItem(QString(

Qt invoking qml function with custom QObject type

和自甴很熟 提交于 2019-12-23 02:52:24
问题 I want to invoke a qml method from c++ passing as a parameter a custom type. This is my custom type (*Note that all the code I post is not exactly what i'm using, i've extracted the relevant parts, so if you try to compile it is possible that some changes have to be made) Custom.h class Custom : public QObject { Q_OBJECT Q_PROPERTY(QString ssid READ getSSID WRITE setSSID) public: Q_INVOKABLE const QString& getSSID() { return m_ssid; } Q_INVOKABLE void setSSID(const QString& ssid) { m_ssid =

QQuickWindow::grabWindow: scene graph already in use

坚强是说给别人听的谎言 提交于 2019-12-23 02:38:10
问题 I tried the code shown here: How to take ScreenShot Qt/QML On execution I am getting the error written in the title. My main.cpp is: #include <QGuiApplication> #include <QQmlApplicationEngine> #include <QQuickWindow> #include <QImage> #include <QDebug> #include "screenshot.h" #include <QQuickView> #include <QQmlContext> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); const char* drigUi = "DrigUI"; qmlRegisterType <screenCapture> (drigUi, 1, 0, "ScreenShot");