qt-creator

Use UI array in a function Qt C++

天涯浪子 提交于 2019-12-25 18:14:42
问题 In my Windows forms code, ui is used to define graphical element by default. But I want to modify them in a function, like this: The problems is that the debug tool tells me that ui is not declared in this scope. #include <QMessageBox> #include <QFile> #include <QTextStream> #include "mainwindow.h" #include "ui_mainwindow.h" #include "datawindow.h" void getData(ui){ QFile inputFile("C:\\pepoles.txt"); if (inputFile.open(QIODevice::ReadOnly)){ QTextStream in(&inputFile); while ( !in.atEnd() ){

Background at Qt Widget

老子叫甜甜 提交于 2019-12-25 08:17:13
问题 I just started my first project in Qt and I have problem with setting background for my QWidget . I added my photo to resources of project in qrc file. After that i edited my widget stylesheets and added there: background-image: url('://resources/assets/subaru.jpg'); Unfortunately, I see my background only in preview editor ui, after compiled background is empty, without image. 来源: https://stackoverflow.com/questions/39830143/background-at-qt-widget

module [] is not installed — registering custom C++ wrapper for QML

一笑奈何 提交于 2019-12-25 07:17:51
问题 I need to access a C++ API to work with CAN bus. Looks like the best solution is to write a QML wrapper to expose all the functionality I need. Here is my canservice.cpp so far: #include "canservice.h" #include <QCanBus> #include <QDebug> #include <QCanBusFrame> #include <QTimer> #include <QtCore/qbytearray.h> #include <QtCore/qvariant.h> #include <QtCore/qdebug.h> CANService::CANService(QObject *parent) : QObject(parent), m_canDevice(nullptr) { QString status = ""; initializeSettings(); //

How to create a custom grouping of properties and apply them to different controls?

ぃ、小莉子 提交于 2019-12-25 06:56:37
问题 I have a window with Buttons, TextFields, Labels etc. These all share common properties like font family, color, size etc. What I would like to be able to do is to define a grouping of these properties (called, say, textStyles.MainTitle or textStyles.DescriptiveText etc.) that would include a font family, size and weight, height and color. And then in the QML file I would write something like: myCustomProperty: textStyles.MainTitle and this would apply those values to the control. How can I

MSVC2013 - Entry Point Not Found

◇◆丶佛笑我妖孽 提交于 2019-12-25 05:34:11
问题 I recently installed the Qt add-inn for visual studio 2013. When I build a project in either Qt Creator or Visual Studio using MSVC2013 it builds without errors, but can only be run from inside the IDE. If I try to run it by clicking the .exe, it gives an error: "The procedure entry point ?qt_metacast@QMenuBar@@UAEPAXPBD@Z could not be located in the dynamic link library". From the research I have done online, I found that it could be something to do about adding the correct .dll files in my

QT Creator 5.7 did not build all modules as static lib

…衆ロ難τιáo~ 提交于 2019-12-25 02:47:28
问题 Couldn't find answer myself. I try to use a power shell script windows-build-qt-static.ps1 to build QT from sources. It's did not working as is, so I modify it. I have download sources manualy, unzip them, place into properly dirrectory, manually patch mkspecs with # [QT-STATIC-PATCH] QMAKE_LFLAGS += -static -static-libgcc QMAKE_CFLAGS_RELEASE -= -O2 QMAKE_CFLAGS_RELEASE += -Os -momit-leaf-frame-pointer DEFINES += QT_STATIC_BUILD and finally I start the power shell script, which contains only

Include libraries into my project folder

女生的网名这么多〃 提交于 2019-12-25 02:43:05
问题 I'm programming using C++ and Qt Creator. I need to include the libraries I'm using inside my project folder so that the program can be implemented on any device. What should I do exactly? I know I should modify the .pro file and I already tried this: LIBS+=-L"$$_PRO_FILE_PWD_/libs" \ -lvl \ But it does not work. I get this error: error while loading shared libraries: libvl.so: cannot open shared object file: No such file or directory Any ideas?? Thanks 回答1: First of all, on Linux qmake

QtCreator: How to compile external source files

心不动则不痛 提交于 2019-12-25 02:38:31
问题 I have my C++ project files and want to create an additional graphical user interface for these sourcefiles. I am using windows, MVSC2012 and Qt 5.1.1 with Qt Creator 2.8.1. So here is what i have: My QtCreator project folder, including the following auto-generated files c:/creatorProject/creatorProject/main.cpp c:/creatorProject/creatorProject/mainwindow.cpp c:/creatorProject/creatorProject/mainwindow.h c:/creatorProject/creatorProject/mainwindow.ui c:/creatorProject/creatorProject

How to call a static function as a SLOT() in Qt? [duplicate]

冷暖自知 提交于 2019-12-25 00:21:25
问题 This question already has answers here : Is it possible to connect a signal to a static slot without a receiver instance? (3 answers) Closed 6 years ago . I am using Qt code in a ROS node. I have declared a static function setLabel() in my class. The role of this function is to put an image into a QLabel. Now, I want to call this function when I click a button using a signal/slot connection. Please tell me what should I put at place of the question mark. class ImageDisplay: public QObject { Q

Qt Creator cannot resolve gvContext on Ubuntu

梦想的初衷 提交于 2019-12-24 23:09:10
问题 I want to write an application in C++ that displays an automaton using graphviz. I tried out a sample taken from documentation but I get 'undefined reference gvContext', along with the other function calls. The sample code I tried is : void create_automaton(int argc, char *argv[]){ Agraph_t *g; Agnode_t *n, *m; Agedge_t *e; Agsym_t *a; GVC_t *gvc; gvc = gvContext(); gvParseArgs(gvc, argc, argv); g = agopen("g", Agdirected, 0); n = agnode(g, "n", 1); m = agnode(g, "m", 1); e = agedge(g, n, m,