qt5

Show Qt3D stuff inside QWidget in Qt5

时光总嘲笑我的痴心妄想 提交于 2019-12-30 11:01:09
问题 So I felt all warm and fuzzy inside after reading that Qt3D has re-emerged in a v2.0 and is in fact becoming a part of Qt5 soon and that parts of it is already available for testing as a tech preview. I set out with a simple plan, I would have Qt3D working inside a widget in my existing C++/widgets based application. However the only example I could find that shows how to use Qt3D from C++ is called basicshapes-cpp, and it shows some shapes rendered in a separate OpenGL/Qt3D prepared window

QT 5.0 QDebug compilation error

断了今生、忘了曾经 提交于 2019-12-30 08:16:57
问题 I am having trouble compiling my code with QDebug, but i really need it. #include <QCoreApplication> #include <QtDebug> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QDebug() << "hello"; return a.exec(); } This is an example of the error i got on this simple test: no matching function for call to 'QDebug::QDebug()' 回答1: Try this: qDebug() << "hello"; 回答2: The problem here is that QDebug does not have a default constructor. QDebug() << "hello"; would work if it did have

Why am I getting “undefined reference to vtable…” errors when linking this Qt 5.0 application?

大兔子大兔子 提交于 2019-12-30 08:12:24
问题 I've got a relatively simple Qt 5.0 project that uses CMake 2.8.9: CMakeLists.txt: cmake_minimum_required(VERSION 2.8.9) set(CMAKE_INCLUDE_CURRENT_DIR ON) project(hello-world) find_package(Qt5Widgets REQUIRED) qt5_wrap_ui(hello-world_UI MainWindow.ui) add_executable(hello-world MainWindow.cpp main.cpp ${hello-world_UI}) qt5_use_modules(hello-world Widgets) MainWindow.h: #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow :

Why am I getting “undefined reference to vtable…” errors when linking this Qt 5.0 application?

核能气质少年 提交于 2019-12-30 08:11:45
问题 I've got a relatively simple Qt 5.0 project that uses CMake 2.8.9: CMakeLists.txt: cmake_minimum_required(VERSION 2.8.9) set(CMAKE_INCLUDE_CURRENT_DIR ON) project(hello-world) find_package(Qt5Widgets REQUIRED) qt5_wrap_ui(hello-world_UI MainWindow.ui) add_executable(hello-world MainWindow.cpp main.cpp ${hello-world_UI}) qt5_use_modules(hello-world Widgets) MainWindow.h: #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow :

Qt5 new signal to lambda connections memory leak

人盡茶涼 提交于 2019-12-30 05:35:07
问题 The new Qt5 signals and slots syntax allows us to connect signals not only to slots, but also to plain old functions and functors/lambdas. Now the problem is, that lambdas are essentialy objects with () operator, and when you connect signals to them, they get copied somewhere in qt internal classes. And, when you disconnect the signal from that functor, it stays in qt internals. I fail to understand, is that a normal behaviour? Or maybe there is a way to destroy those functional objects after

How to create grouped/nested properties?

人盡茶涼 提交于 2019-12-30 03:23:07
问题 I am trying to do nested properties like 'font.family' or 'anchors.fill', but I cannot initialize them in normal way because it prints 'Cannot assign to non-existent property'. Instead I am forced to use Component.onCompleted method. What's wrong? MyButtonStyling.qml: import QtQml 2.1 QtObject { property QtObject background: QtObject { property color pressed: "#CCCCCC" property color enabled: "#666666" property color disabled: "#555555" } } main.qml: import QtQuick 2.0 Item { width: 400

Create QML Element in C++?

独自空忆成欢 提交于 2019-12-30 03:22:06
问题 I have the following problem: I load an initial interface into a QQuickView using a .qml file. I then want to add QML types like an Image or Text to the interface using C++. I know I can manipulate existing elements from C++ but how can I create new types and add them? 回答1: Unfortunately the docs are a bit out-of-date (uses Qt4 api), but If you read section Loading QML Components from C++ here: https://doc.qt.io/qt-4.8/qtbinding.html Then you should have something like (with Qt5 api):

How to highlight the entire row on mouse hover in QTableWidget: Qt5

假装没事ソ 提交于 2019-12-29 07:44:13
问题 I want to highlight the row on mouse hover in my QTableWidget . When I hover the mouse, only single cell highlighted. I have tried this approach : bool MyTabWidget::eventFilter(QObject *target, QEvent *event) { if( target == ui->MyTableWidget ) { //Just to print the event type qDebug() <<"EventType : "<<event->type(); } } Output : EventType : 13 . `(13 = QEvent::Move)` I have done lost of googling. but not get any proper solution. Is there any other approach to fulfill my requirment (to

How to read complete data in QTcpSocket?

纵饮孤独 提交于 2019-12-29 07:42:09
问题 Now the server (implemented with java) will send some stream data to me, my code is like below: connect(socket, SIGNAL(readyRead()), this, SLOT(read_from_server())); in the read_from_server() : { while (socket->bytesAvailable()) { QString temp = socket->readAll(); } } but I find that even the server sent me a string with only several characters, the data is truncated, and my function is called twice, thus temp is the never complete data that I want. If server send me a longer string, my

How can I simply parse a CSS like (!) file in my Qt application?

我怕爱的太早我们不能终老 提交于 2019-12-29 06:51:08
问题 I have a document in a *.css (Cascading Style Sheets) like format, but it has its own keywords. Actually it is a personalized css (I call it *.pss), with own tags and properties. here I have an excerpt: /* CSS like style sheet file *.pss */ @include "otherStyleSheet.pss"; /* comment */ [propertyID="1230000"] { fillColor : #f3f1ed; minSize : 5; lineWidth : 3; } /* sphere */ [propertyID="124???|123000"] { lineType : dotted; } /* square */ [propertyID="125???"] { lineType : thinline; } /* ring *