FAQ Database Discussion Community


QDomDocument toString

xml,dom,qt5
Running the below code does not produce the same ordering of attributes each time. Why is this happening? QDomDocument dom; QDomElement element= dom.createElement("MyElement"); element.setAttribute("attr1", "foo"); element.setAttribute("attr2", "bar"); element.setAttribute("attr3", "hello"); dom.appendChild(element); QString text = dom.toString(); I am aware that the xml specification says ordering of attribute is not significant but I...

Qt5: function.toString() not working

javascript,qt,qml,qt5
I use Javascript in my QML application and want to insert the code of a function as string: function test(parameter) { console.log("Something to do!"); } ... function otherFunction(otherParam) { console.log("Output: "+test.toString()); } All this does is to print the following: "Output: function() { [code] }" instead of the desired string:...

How do I create a qt app in nim

linux,qt5,qtgui,nim,nimrod
I'm looking to use nim in an upcoming project, but I'm not sure where to start. I've worked on a fair few webapps over the last two years and I'm pretty good with python. I'm also very good with Linux. Now I want to make a GUI app for linux,...

how to suppress namespace prefix with Qt5.4 QXmlStreamWriter

xml,qt,qt5,xml-namespaces,qt5.4
I have this dictionary.xml: <?xml version="1.0" encoding="UTF-8"?> <DictionarySet xmlns:mc="urn:fmosoft-map-creator" xmlns="urn:fmosoft-map-creator" Version="1"> <Dictionary SourceLanguage="en_US" SourceLanguageIsPredefined="true" TargetLanguage="es" TargetLanguageIsPredefined="true"> <Translation Source="asdf" Target="fdsa"/> <Translation Source="xyz" Target="jkl"/> </Dictionary> <Dictionary SourceLanguage="en_US" SourceLanguageIsPredefined="true" TargetLanguage="pt"...

How to run custom commands during `make uninstall` from qmake in QT5?

c++,qt,makefile,qt5,qmake
I have a QT project that installs a service to the system, when running make install. The relevant parts of the .pro file are the following: init.path = /etc/init.d/ init.files = myservicename updaterc.path = /etc/init.d/ updaterc.extra = chmod 755 $$init.files; \ update-rc.d $$init.files defaults 97 03; \ service $$init.files start...

C++ Abstract Class error on Constructor in Qt 5

c++,constructor,abstract-class,qt5
I'm creating a simple abstract class named Asset, the header code looks like this: #ifndef ASSET_H #define ASSET_H #include <QString> #include <QDate> class Asset { public: Asset(QString des, QDate dat); ~Asset(); virtual QString toString(); virtual double value(); QString getDescription(); private: QString description; protected: QDate date; }; #endif // ASSET_H This...

Qt5 - How to make qurl detect wether the given url is local or not and add “http://” if not?

qt,qt5,qurl
QUrl class can be used to open both local or online file. I used QLineEdit to take URL as QString and give it to QUrl. The program can access both local and online file. My point question is: is there any official way to automatically detect if the given url...

QTabWidget does not respect spacing from layout

qt,qt5,qtabwidget
I have this test case: // Scroll QScrollArea *sa = new QScrollArea(ui->centralWidget); sa->setWidgetResizable( true ); // Layout for widgets QVBoxLayout *vl_2 = new QVBoxLayout(); vl_2->setSpacing(0); // Widget to attach the scroll to and the layout QWidget *widget = new QWidget() widget->setLayout(vl_2); sa->setWidget(widget); // Test widgets QComboBox *cb_1 = new QComboBox();...

How to compile Qt 5 projects without QtCreator?

c++,eclipse,cmake,qt5,kdevelop
I tried to modify KDevelop Qt 4 CMake project to be compile it with Qt 5 and changed the project, but I failed. I'm still learning Qt and the project's simple. Commented lines are replaced to make it a Qt 5 project. main.cpp: //#include <QtGui/QApplication> #include <qt5/QtWidgets/QApplication> #include "Qt4_Training.h" int...

Where did file downloaded with PyQt5 network access manager go? And how do I save it?

qt,qt5,pyqt5,qnetworkaccessmanager,qnetworkreply
Without specifying file to save, I created this: def start_download(self): self.reply = self.manager.get(QNetworkRequest(QUrl(self.url_edit.text()))) self.reply.downloadProgress.connect(self.download_progress) self.label.setText(self.url_edit.text()) def download_progress(self, received, total): print(received, type(received)) The last function I mentioned did write received byte. So, the is downloaded. Where did it go without I specified path to save? And How can I save it?...

TableView in QT5 doesn't show MYSQL Data, just empty rows are shown

c++,mysql,qt,tableview,qt5
I am showing you my problem by showing a screen shot. This seems easier to me. My Table is empty in my program, but it has the right amount of columns and if I add more columns in my sql workbench it will get more rows, but nothing is displayed...

Qt5.4 QAudioOutput on Raspberry Pi With PulseAudio on the 3.5mm Audio Jack Doesn't work but Qt 5.3 Does

qt,raspberry-pi,qt5,alsa,pulseaudio
Qt5.3 sees the default Raspberry Pi also_output.0.analog-mono device ( 3.5 mm headphone jack ) and QAudioOutput from 5.3 successfully writes audio to that device and I can hear the audio with my headphones. This all works with default Raspbian, with PulseAudio 2.0 from apt-get, and no extra configuration. PulseAudio is...

How to react to 'Close window' in right-click menu of task bar in Windows

windows,qt,qt5
Using Qt 5.3.0 and Windows 8.1: Don't know if I'm missing something or if this is an oversight in Qt, but when I simply have a QMainWindow that opens a QDialog (with exec()) and then try to use the 'Close window' function of the right-click menu of the Windows task...

Drawing errors and crash with QWidget::createWindowContainer

c++,qt,qt5
In my Qt 5.3 application, I want to integrate the GUI from a child process into my main process' window: The child process creates a top-level QWidget. The child process communicates the widget's WId as returned from QWidget::winId() to the parent (using IPC). The parent uses QWindow::fromWinId() and QWidget::createWindowContainer() to...

QWebView or QWebEngineView

qt,qt5,qtwebkit,qt5.4,qtwebengine
Starting new project today (well, not today, but in week or two), what should one use? QWebView or QWebEngineView? Are there any functional differences between those two? If I understand correctly, QWebView is webkit, while QWebEngineView is blink. Are there any differences to the programmer? And most importantly, does one...

What is the difference between QAndroidJniObject::callMethod() and QAndroidJniObject::callObjectMethod()?

android,c++,qt,qt5,qtandroidextras
I noticed that the Qt documentation offers two methods for calling android native methods but I can't figure out when to use QAndroidJniObject::callMethod and when to use QAndroidJniObject::callObjectMethod. What is the rule?

Force Qt5 to load SSL dlls from exe dir

c++,windows,qt,dll,qt5
Update Sorry, guys, I was incorrectly determined the problem. All is working, error was in "other program logic". Please delete or close the question. Qt5 is designed to load libeay32.dll and ssleay32.dll on program start before any instruction in main() (because it is static). (Details: it is located in qtbase\src\network\ssl\qsslsocket_openssl_symbols.cpp:...

QToolButton with icon + text: How to center both?

qt,qt5,text-alignment,qstyle,qstylesheet
I am using multiple QToolButtons in a custom QGridLayout widget. The buttons are set to display icon + text based on an assigned default QAction. The only issue is that the content (icon + text) is always left-aligned. The content (icon + text, marked as a red box in the...

QT5 qml receive c++ object in slot

qt,qml,qt5,qtquick2
i want to send a c++ object to QML via signal-slot. class TaskInfo : public QObject { Q_OBJECT Q_PROPERTY(QString name READ taskName) ... // constructors public: TaskInfo(); TaskInfo(QIODevice *in); TaskInfo(TaskInfo &&taskInfo); TaskInfo(const TaskInfo &taskInfo); // it's just copy all variable ... } and i have a class to send TaskInfo...

Even width of Text and Textfield

qt,qml,qt5,qtquick2
I have a simple login form written in QML with a custom component, MediumText, and two TextFields. Unfortunately, I'm not able to properly align the elements, as shown by the following picture: I want the labels to the left (MediumText type), as well as the TextField instances on the right,...

How can I get the used configure commandline options for the installed Qt5

qt5,configure
I want to check if Qt5 was compiled with or without some options, regarding supported image formats. I know about the QImageReader supportedImageFormats function but I want to know the configure options. Is there a way to retrieve the used commandline options of the configure call dynamically? Cheers....

Cmake and Qt5 linking error

c++,qt,cmake,qt5
I'm trying to build a Qt5 project with Cmake in order to add some new librairies. The cmake goes well but I have a linking issue when building : Linking CXX executable bin/qGo CMakeFiles/qGo.dir/src/main.cpp.o: dans la fonction « main »: main.cpp:(.text+0x102b): undefined reference to « qInitResources_application() » collect2: error: ld...

How to prevent clipping of cornerWidget in QMenuBar

qt,qt5,qmenubar
I'm writing newbie Qt5(.4.0) code on OSX Mavericks. Here's my self-contained test case: #include <QApplication> #include <QMainWindow> #include <QtGui> #include <QMenuBar> #include <QGridLayout> #include <QPushButton> int main( int argc, char *argv[] ) { QApplication app( argc, argv ); QMainWindow* mw = new QMainWindow(); mw->menuBar()->setNativeMenuBar( false ); QMenu* fileMenu = mw->menuBar()->addMenu(...

How to prevent tab buttons from shrinking in QTabWidget

qt,tabs,qt5,qtabwidget,qtabbar
How do I prevent the tab buttons of a Qt5 QTabWidget from shrinking, thus obscuring the full tab names, when I shrink the containing window? Here's a self-contained example of the problem: #include <QApplication> #include <QMainWindow> #include <QtGui> #include <QTableWidget> QTableWidget* makeTableWidget( QWidget* parent ) { QTableWidget* tableWidget = new...

QMutex in slots

c++,qt,qt5,mutex
Suppose to have the following QT code (QT 5.3.1): void SenderClass::runSignal() { emit mySignal(); } void ReceiverClass::ReceiverClass() { ... connect (senderClassRef, SIGNAL(mySignal()), this, SLOT(mySlot()) ); } void ReceiverClass::mySlot() { //Long operation executions Sleep(1000); qDebug() << "1"; Sleep(1000); qDebug() << "2"; Sleep(1000); qDebug() << "3"; } Calling runSignal() consecutively it happens...

Increase font size in Qt

qt,fonts,qt5
I have a GUI with some math symbols that might be hard to read at the default font size, so I would like to create a QFont object that has a size of system_default+4. However, there doesn't seem to be a way to get the default size in the first...

Endian safe conversion of two chars to unsigned short

c++,qt,qt5
I am working with a function that takes two chars, representing an unsigned 16 bit integer, as arguments. I need to convert these values back to an unsigned integer and I would like the method to be endian-safe. I have come up with the method below but I'd like to...

detect when mouse cursor is over an irregular shape picture in Qt5 and QML

qt,qml,qt5
I'm developing a little application with Qt5 and QML (QtCreator and C++). I would like to display a map with countries and when user passes the mouse over a country I would like to change the color of the country, thought it would be easy, and it is if all...

WA_DeleteOnClose delete all members?

c++,delete,heap,qt5,destructor
I'm in trouble with Qt5's WA_DeleteOnClose attribute. This is the situation: I have a class M that extends QMainWindow, and in this class I use an heap-allocated array. I read that with WA_DeleteOnClose when the window M is closed, and the destructor called, every member with M as parent is...

QApplication dont exit after i close all QWidget

c++,qt5
I am programming a application that return a value with QWidget::exec, but seem that i cant close the class properly (i need call Gate::~Gate explicitly for delete the class) and QApplication::exec never exit. Gate is the main window of my aplication Gate::Gate(List *opciones, QWidget *parent): QDialog(parent), ui(new Ui::Gate) { ParseOption...

How do I highlight specific letters in the text of a QListWidgetItem?

c++,css,qt,qt5
I am writing a search algorithm that searches a QListWidget and returns relevant matches based on what the user types in the search bar. I would like any matches to be highlighted in a yellowish color. For example: If the user types "ilt" into the search bar, I would like...

QML (Qt 5): Overlay button on top left corner of resized image

qt,qml,qt5,qtquick2
I have this code (reduced to minimal): import QtQuick 2.0 import QtQuick.Controls 1.3 Item { Image { id: img source: "cluster.png" width: 150 height: 150 fillMode: Image.PreserveAspectFit } Button { id: butn anchors.left: img.left anchors.top: img.top width: 20 height: 20 text: "Push!" } } Which produces an image similar to...

Pro file directive: copy target to folder at build step

qt,qt5
I have a TEMPLATE = subdirs project with 6 subprojects which build in specified order. I would like to copy the output file of project1 (it's target) to some folder. This folder is passed with LIBS += -L to project2 and project2 may use this file as a static library....

Git Clone QT5 Gitorious

git,qt5,gitorious
I can't clone QT5 from gitorious anymore. This used to work: git clone git://gitorious.org/qt/qt5.git --branch v5.3.1 --single-branch 5_3_1_x64_msvc2012 Now the command above returns with error: "fatal: could not read from remote repository. Please make sure you have the correct access rights and the repository exists." Unfortunatly the Qt wiki page...

How to set User Agent in QtWebEngine QML application

qt,qml,qt5,user-agent,qtwebengine
NOTE: I was able to do that on QtWebKit QML using the QtWebView extension. Here I am interested in using QtWebEngine. My simple test application import QtQuick 2.1 import QtQuick.Controls 1.1 import QtWebEngine 1.0 ApplicationWindow { width: 800 height: 600 color: "lightgray" visible: true WebEngineView { id: webview url:...

LibHaru QT5 cannot find usr/local/lib, file format not recognized

qt,qt5,ubuntu-14.04,libharu
I installed libraries from libharu.org accordingly to the instructions on the page(without any errors). Then tried to run an example in qt5. After adding paths to installed directories INCLUDEPATH +=/usr/local/include LIBS +=/usr/local/lib -libhpdf qt5 seemed to found them (headers underline disappeared). However during debug it shows errors cannot find /usr/local/lib:...

Simple Qt app doesn't open on Mac OSX Yosemite

c++,osx,qt,qt5
Environment Mac OSX Yosemite Qt5 3 files main.cpp main.qml webengine.pro main.cpp #include <QtGui/QGuiApplication> #include <QtQml/QQmlApplicationEngine> #include <QtWebEngine/qtwebengineglobal.h> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QtWebEngine::initialize(); QQmlApplicationEngine engine; engine.load(QUrl("main.qml")); return app.exec(); } main.qml import QtQuick 2.0 import QtWebEngine 1.0 import QtQuick.Controls 1.3 import QtQuick.Window 2.0 ApplicationWindow { title: qsTr("Test")...

Is it possible to control multiple VideoWidgets with one MediaPlayer?

qt,qt5,qmediaplayer
I wonder if it is possible to play a video using the Qt5 QtMultimedia library in 3 widgets simultaneously. I have a video that I would like to show in 3 widgets: one showing the full video, another focusing on some object moving in the video, and a last one...

why received the following error when using QT5?

c++,qt,qt5
I am getting the following errors when I build a sample code using QT5, Visual Studio 2012 x64, static inline qint64 nullJd() { return std::numeric_limits<qint64>::min(); } 1>c:\qt\qt5.1.1\5.1.1\msvc2012_64_opengl\include\qtcore\qdatetime.h(121): warning C4003: not enough actual parameters for macro 'min' 1>c:\qt\qt5.1.1\5.1.1\msvc2012_64_opengl\include\qtcore\qdatetime.h(121): error C2589: '(' : illegal token on right side of '::' 1>c:\qt\qt5.1.1\5.1.1\msvc2012_64_opengl\include\qtcore\qdatetime.h(121): error...

How to share build step in Qt Creator

qt,qt-creator,qt5,qmake
Qt Creator has an option to add custom build steps for the project which is cool. However the command line for the additional build step is stored in the .pro.user file which should not be added to version control, because it contains machine specific data. When I push my project...

QSerialPort new signal slot syntax no matching member function for call to 'connect'

c++,qt,qt5,qtserialport
I am trying to use the new signal and slot syntax, but I am getting a compile error at connect function. How to use the new syntax in this case? // Qt 5.4.1, Apple LLVM version 6.1.0 and qmake 3.0 private slots: void onError(QSerialPort::SerialPortError code); private: QSerialPort *m_port; Link::Link(QObject *parent)...

How to make a QSlider read-only?

qt,qt5,qslider
Using Qt 5.2.1 Is it possible to set a QSlider (doesn't matter if it's horizontal or vertical) to read-only that is user cannot change the value of the slider but only use it as an indicator of some sort? I was unable to find anything in the Qt documentation or...

Is it possible to deploy a Qt Quick application without Qt Network on OS X?

qt,qt5,qt-quick,qtnetwork
I have a Qt Quick application using the following modules QT = core gui qml quick widgets \ core-private gui-private \ multimedia printsupport` which I deploy on OS X. Now my main binary as well as a lot of Qt Qtick plugins show a dependency on Qt Network. otool -L...

How to obtain entire Qt StyleSheet for QMacStyle

qt,qt5,qstylesheet
Is it possible to obtain a text file of the entire Qt5 StyleSheet for QMacStyle (or its equivalent QProxyStyle that's apparently used in Qt5)? I'm hoping to get a list of all the property:value pairs ('background-color', 'border-radius', 'margin-top', 'padding', etc.), along with their default settings, that are used for each...

How to make intermediate object file not a library using qmake?

qt5,static-linking,qmake
Filesystem layout: MyProject |_ myproject.pro |_ FuncA |_ core.cpp |_ core.h |_ core.pro |_ app |_ main.cpp |_ app.pro I want just to compile "core.cpp" in FuncA to make a object file not a library. That is "gcc -c core.cpp". And in app I want to make main program linking...

How do I get the return value of the EXISTS operator with QtSql?

c++,qt,sqlite,qt5
The EXISTS operator always evaluates to one of the integer values 0 and 1. I tried to get them via QSqlQuery::value(int index). But somehow this result is not related to a column. How do I get the return value of the EXISTS operator with QtSql? query.prepare("SELECT EXISTS(SELECT 1 FROM files...

qmake's write_file() and system() doesn't want to make a file

qt,qt5,qmake
I've got a strange behavior of qmake while trying to write smth to another file. I read all possible manuals and searched out the internet but found nothing similiar. Closer to the simplest possible code: !system(echo 1 > d:\1.txt) { warning(Cant create a file) } It doesn't create a file,...

How to enable/disable WebKit features when compiling as part of Qt5 library

c++,qt,webkit,qt5,qtwebkit
When you compile QtWebKit separately from Qt5, you have access to a bunch of compilation options, like --no-webkit2, --no-3d-rendering, --no-video and others. It seems that when you compile WebKit as part of the Qt5 library, you get stuck with predefined feature configuration which you cannot modify. Is it possible to...

linux gst_element_factory_make (“rtspsrc”, NULL) fails on qt5

linux,qt5,gstreamer,rtsp
My problem is, why does gst_element_factory_make ("rtspsrc", NULL) fails evry times? I use Qt5 on ubuntu 14.04. I tried gst_element_factory_find ("rtspsrc") with success, I also tried gst-ispect rtspsrc gst-inspect-0.10 rtspsrc gst-inspect-1.0 rtspsrc and all successfully here are link I found on tiku.io, on stackoverflow, on quabr.com and I tried to...

Encoding a QString in JSON

qt,qt5,qwebelement
I'm trying to encode a QString into a JSON string, so that I can inject it safely via QWebFrame::evaluateJavaScript(QString("o.text = %1;").arg(???)). For example, in php using the function json_encode echo json_encode('HELLO "me"'); The output would be "HELLO \"me\"" This is the internal representation of the string, within the Json object....

python 3 how to put pics inside my program

image,python-3.x,qt5,py2exe
I have a program and couple of pics which I use in the program. icon.addPixmap(QtGui.QPixmap("logo_p3.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.label_6.setPixmap(QtGui.QPixmap("Logo-4.jpg")) Pics are in the same folder with the program. Is there any way to put pics INSIDE the program? (While they are just in the folder they can be easily changed or...

QML ScrollView with ColumnLayout

c++,layout,qml,qt5
I am trying to create a scroll view around a ColumnLayout, unfortunately my current code doesn't work. I know about ListView, but in my case I need to create scrollable Layout, because it will contain heterogeneous elements. ApplicationWindow { id: mainwindow title: qsTr("Hello World") width: 300 height: 300 visible: true...

qt5 fstream doesnt work

qt,qt5,fstream
I have some Code its working when i compile it with Code Blocks, so now that i want to use it in QT5 i copied it. And its doing nothing. i can run the Application, but i can not read data out of my txt file. I included fstream, string,...

DPI-independent constant size in QML

qt,qml,qt5,qtquick2,qt-quick
I have a visual component in my app written in QML, Qt5. I want it to always have the width of 5 cm on the screen, no matter what device is used. If I set width: somevalue, then the DPI might differ among the devices which will result in different...

How to override just one property:value pair in Qt StyleSheet

qt,qt5,qpushbutton,qstylesheet
I am writing newbie Qt5 code on OSX Mavericks and would like to override just one property:value pair of the StyleSheet for a given widget. If I run the following self-contained demonstration code: #include <QApplication> #include <QMainWindow> #include <QtGui> #include <QPushButton> int main( int argc, char *argv[] ) { QApplication...

How to display QVector3D in one cell in QTableView via qAbstractTableModel's subclass

c++,qt,qt5,qtableview,qvector3d
I'd like to display QVector3D in tableView, preferably like this: (x,y,z). I had subclassed the QAbstractTableModel class and implemented QAbstractTableModelSublass::data function: QVariant data(const QModelIndex &index, int role= Qt::DisplayRole) const override { ... if(role == Qt::DisplayRole) { /* decide in which column and row to display the data*/ QVector3D p(1.,2.,3.); return...

Qt - Draw on canvas

qt,drawing,qt5
I am trying to write a program using Qt5 that allows users to draw on canvas like paint. I know that the program has to handle events such as mousePressEvent(), mouseReleaseEvent(), and mouseMoveEvent(). But I am not able to figure out how to use them. Can you guys give me...

Qt/C++ how to wait a slot when signal emitted

c++,multithreading,qt5,signals-slots
I have developed an app in Qt/C++, I have used signal/slot mechanism to interact between 2 threads. the first thread run the UI/TreeWidget and the second one run the framework I got an issue on one action. In the UI side, before starting my action, I'm connect signal/slot between UI...

Linux Netcat works as Expected but not QTCPSocket on Raspberry Pi

linux,qt,tcp,qt5,qtcpsocket
I have 2 Raspberry Pis, one sender and one receiver which acts as an Access Point using a USB WiFi dongle. I have Qt 5.4.0 code on the sender that uses a USB/FTDI XBee SB6 WiFi unit to send TCP packets to the receiver Pi after connecting to it's Access...

Undesired auto scrolling of QComboBoxes

c++,qt,qt5
I discovered that in the latest Qt versions (currently I use 5.4.1 but it was the same in 5.2) if I add several items to a QComboBox and I position the mouse cursor in specific positions it will scroll itself which is really annoying ... I think. I've got a...

libcurl curl_easy_perform() crashes program when moved inside function

c++,qt5,libcurl
Using Qt5 with the libcurl library, I try and download a directory listing from my local FTP server. If I keep all the curl_easy_setopt() and curl_easy_perform() in main(), it works perfectly. However if I try and put them all in a function for a single call, the program crashes when...

QToolButton with text: Overwrite minimal height to minic regular button height

qt,qt5,qgridlayout,qaction,qsizepolicy
I am displaying QToolButtons with icon plus text (Qt::ToolButtonTextBesideIcon) outside of a tool bar. Each button has a Qt::Action associated with it which determines the used icon and the displayed text. All those buttons are placed inside a QGridLayout. So far so good. Unfortunately, it looks like that as soon...

Context switches between functions and slots in a single thread?

multithreading,qt,qt5
I am implementing a small project where I am extensively using QThreads and signals/slots (and basically Qt 5). I can say I have a fair idea about how signals/slots work along with QThreads. (I have gone through all important material on StackExchange as well as these links "You are doing...

Overlay while loading page into QWebView

c++,qt,qt5
Let's say we have a barebones QWebView: #include <QApplication> #include <QWebView> int main(int argc, char** argv) { QApplication app(argc, argv); QWebView view; view.show(); view.setUrl(QUrl("http://google.com")); return app.exec(); } How can I display a graphic overlay, preferably fullscreen with transparency and minimal animation (like timer/beachball/etc.) from when the page starts loading till...

QStackedLayout implicitly shows added widget

c++,qt,qt5
Considering the simple application #include <QtWidgets> int main(int argc, char **argv) { QApplication app(argc, argv); QStackedLayout stack; stack.addWidget(new QLabel("Calls QLabel::show()?")); return app.exec(); } with qmake project TEMPLATE = app TARGET = main QT += widgets CONFIG += c++11 SOURCES += main.cpp one would intuitionally expect an application without any UI,...

Qt.inputMethod.show () doesn't show any keyboard

qt,qml,qt5,qtquick2
Considering "Property and Method Changes" from here: TextInput and TextEdit's openSoftwareInputPanel() and closeSoftwareInputPanel() methods have been removed. Use the new Qt.inputMethod property and call Qt.inputMethod.show() Qt.inputMethod.hide() to show and hide the virtual keyboard. I've written the simple example below. import QtQuick 2.3 import QtQuick.Window 2.2 Window { id: root visible:...

Qt4 to Qt5: QPainter::drawPixmapFragments() with 5 arguments - how to solve? (Updated)

c++,qt,qt5,qt4.8,qt5.4
Qt 4.8 (4.8.6) has a QPainter::drawPixmapFragments() overloaded function with 5 arguments: void drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, const QPixmap &pixmap, PixmapFragmentHints hints = 0); Qt 5 (5.4.1) has no such function, it has only one (same as in Qt 4.8) with 4 arguments: void drawPixmapFragments(const PixmapFragment *fragments,...

Qt X11BypassWindowManagerHint open QFileDialog crash

qt,qt5,x11,cinnamon
I have a QMainWindow with windows flag set to be X11BypassWindowManagerHint. There is a QPushButton in the window triggering a QFileDialog. When the event is triggered, cinnamon will crash. When the flag is removed, there will be no crash. Please note that the window is required to always stay on...

QOpenGLWidget overriding projection matrix

qt,opengl,qt5
I am using Qt 5.4 and setting up the projection matrix and viewport as follows in my resizeGL function override: glViewport(_off_x, _off_y, _width, _height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, _width, 0, _height, -1, 1); I can verify this and when I print out the projection matrix as follows, it shows the correct...

QRegularExpression find match with captured length backwards

c++,qt,qt5,qregularexpression
I can find previous match with this, but what I can't do, is to capture the length of the matched string: int pos = 0; if((pos = text.lastIndexOf(QRegularExpression(pattern), cursorPosition - 1)) != -1)) cout << "Match at position: " << pos << endl; I can capture the length of the...

QDataStream allocation between members

c++,qt,qt5,qdatastream
class ReadFile { public: void init(); QList<double> getData(); private: QFile file; QDataStream read; double bufferFloat; quint32 bufferInteger } The idea is now that when init() is called, the a file should be opened and navigated into a location where the data starts. Now, every time getData() is called, a chunk...

CSS to access QHeaderView item columns to set bacround-image, or set large icon to QHeaderView

css,qt,qt5,qheaderview
I need CSS access to all columns of the QHeaderView to set backround image to the first column i can access via: QHeaderView::section:horizontal:first{ background-image: url(:/Icons/icon_1.png); background-position:left; background-repeat:no-repeat; border: 1px solid #4B4B4B; } to the last column i can access via: QHeaderView::section:horizontal:last{ background-image: url(:/Icons/icon_5.png); background-position:left; background-repeat:no-repeat; border: 1px solid #4B4B4B; }...

Easy readout from QDataStream to QStringList

c++,qt,c++11,qt5,qt5.4
I am reading from a binary file, and want to insert into a QList. Is there an easier way to do the following? (e.g. in one line) QStringList traceNames; for(qint64 i=0; i<numTraces; i++) { QString name; stream >> name; traceNames << name; } stream is a QDataStream. I was thinking...

Is there any way to skip macro replacement(During preprocessing) when macro is used as a variable name?

c++,qt,c++11,macros,qt5
ConflictHeader.h #define _c 6 //This is third party header, canot change, since // there is no sorce code to rebuild testclass.h #ifndef TESTCLASS_H #define TESTCLASS_H #include <QObject> #include "ConflictHeader.h"//Include conflicted header class TestClass : public QObject { Q_OBJECT public: TestClass(QObject *parent); ~TestClass(); private: }; #endif // TESTCLASS_H testclass.cpp #include "testclass.h"...

How to setText for QPlainTextEdit?

qt,qt5,settext
Qt5's documentation doesn't mention that QPlainTextEdit has setText(QString) like QTextEdit does. But, I don't think it's impossible. The only way I found is to use QTextDocument which can has setPlainText(const QString& text). So I have to do this: plain_text_edit->setDocument(text_document); The problem is text_document should be a pointer. Not like QTextEdit's...

Strange error while trying to deploy qt5 app on raspberry pi

c++,linux,raspberry-pi,qt5,raspbian
I have a project which I've made on Ubuntu 14.04 LTS, but then, I wanted to test if the Raspberry Pi was capable of running this little program of mine. Then I've followed the instructions on this link to compile and build qt5 natively on the Pi. I've managed to...

How to move class in the same thread

c++,qt,qt5,qthread
I'm trying the add threading in my app write in C++ and QT. I have a class Framework and one name DeviceMngr. The framework.h is defined as below: class Framework : public QObject { Q_OBJECT QThread FrameWorkThread; public: Framework(); The framework is initialized by the main. My Main is just...

Single quotes prevent bindValue from replacing placeholder mark

c++,qt,sqlite,qt5,qtsql
When I prepare a statement with bindValue the placeholder mark is not replaced if it is surrounded with single quotes. This is problematic since in SQL strings are surrounded by single quotes to avoid keyword conflicts. See my attachements with screenies of the content of the database once inserted with...

How to embed a custom font in my application

c++,qt,qt5
I want to add a custom font to my application, and I have already added to my resource file. And my code as the following: int id = QFontDatabase::addApplicationFont(":/fonts/ae_AlMateen.ttf"); QMessageBox::information(this,"Message",QString::number(id)); Also the content of .qrc file. <RCC> <qresource prefix="/fonts"> <file alias="ae_AlMateen">ae_AlMateen.ttf</file> </qresource> </RCC> But the problem is that the addApplicationFont...

Window on top of another window?

c++,qt,qt5,always-on-top
I want one window to stay above my MainWindow so I use this->setWindowFlags(Qt::WindowStaysOnTopHint); This makes the window stay on top of EVERY window (also from other applications). Also it is above QMessageBox Windows and blocks them. I want them to appear on top of that window. How can I do...

How in Qt5 to check if url is available?

qt,network-programming,qt5
Using Qt5, how to simply check if given url is available? Not using special functions for signal slots, but simply using something like bool isUrlAvailable(QString url), are there any function like this? Update QUrl.isValid() is incorrect answer, it is just checks if url is correctly formed. Update 2 QUrl.host() is...

setting wrapMode property of Text in ScrollView

qt,qml,qt5,qtquick2
I wrote QML like this: import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 import App 0.1 ApplicationWindow { id: appWindow visible: true width: 300 height: 500 ColumnLayout { ScrollView { ColumnLayout { Text { width: 250 text: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor...

Qt convert ISO date to QDate

c++,qt,qt5
Hello I am newbie in Qt and new learning Qt. And for now I've problem to convert ISO date to Qdate. Example I've ISO date like this: 2015-05-17T05:16:22.126Z and now how to convert it to be like this "yyyy-mm-dd" or "yyyymmdd"? Please help me. :D...

Setting Up OpenGL in Qt for QOpenGLWidget

c++,qt,opengl,qt5
I have some old OpenGL code that I created with GLEW. I am trying to port this code into Qt 5.4, the old code contains Mesh, Shader, and Texture classes. What I have so far in Qt, is the default main window and a Visualizer class which inherits from QOpenGLWidget...

Limit QKeySequence/QKeySequenceEdit to only one shortcut

c++,qt,qt5,qkeyevent,qkeysequence
Is it possible to limit QKeySequence to show only one shortcut in QKeySequenceEdit? Currently now it supports up to 4 shortcuts. My application supports key sequences of only one shortcut, e.g. Ctrl+A or Ctrl+C and not e.g. Ctrl+A, D or Ctrl+C, X, Z. Is it possible to limit QKeySequence or...

How do I compile Qt5 dev branch from git repository for the Raspberry Pi?

qt,raspberry-pi,cross-platform,qt5,raspbian
There are a few tutorials on the net, which explain how to compile Qt5 for the Raspberry Pi. Unfortunately all of them are a bit out of date. Usually one gets 'undefined references' for some GLIBC functions. This question and answer explains how to create an up-to-date (March 2015) gcc...

QJSonArray to QString conversion

c++,qt5,qstring
I have this 2 variables, and I want to convert data to dataToString. QJSonArray data; Qstring dataToString; In data there is a huge json like: { "properties": [ { "version":"1", "finish":"0", "num":3, "running":false, "time":"00:20:00", "player1":"John", "player2":"", "player3": "Peter", "player4":"", "team1":"", "team2":"", "tournament":"", "lap":"" } ], "game": [ { "serve":true, "score":"32",...

Building vtk with QT5 windows 8

windows,cmake,qt5,vtk
I'm facing a rather weird error. I can see on the wiki that we can build vtk with support for qt5. However, when trying to do so and first configuring with cmake I get the following output: CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindQt4.cmake:1326 (message): Found unsuitable Qt version "5.4.2" from...

how to use QFtp::list and QFtp::listInfo to check if directory exists

c++,qt,ftp,qt5
I try to make ftp uploader which creates automatically subdirectories and put files in them. My problem is that: my uploader doesn't upload files if directory already exists. it fails on next mkdir (no error just it doesnt upload file). I know QFtp have list() and listInfo() but I don't...

How to open/close file at a specific entry in Qt5

c++,io,qt5
I'm making a program that needs to be able to edit files at specific points, specific lines won't do since the line count will change over time. I plan to do this with qt's textEdit menu element. So for example lets say I have a file that has a comment...

catch mouseMoveEvent on Qt5's QQuickItem

c++,qt,qml,qt5
I'm following the reply of my previous question. But I got stuck U_U. I'm developing a Qt5 application where I want to catch mouseMoveEvent event when the mouse hovers a QQuickItem item. But I don't know how to make it work. I have isolated the problematic code (using this code):...

Windows C++ GUI application

c++,windows,visual-studio,cmake,qt5
I am currently working on porting my C++ Qt5/CMake application from linux to windows. When start application in linux, i see UI and all ok. On windows first start black terminal and from terminal start my application. How start application without black console? It is not beautiful. I am using...

Qt event for delegate in table

qt,qt5,qtableview,qitemdelegate
Question/Issue I tried reimplementing the event method in a custom delegate to handle clicks. The delegate is used to render table cells in a table view. However, I do not get any events for the delegate (the method is never called according to the debuger). Is there anything special I...

How to check two QLineEdit If they are not empty

c++,qt,qt5
I have three controls, two QTextLine and one QPushButton. When startup the program, the add button will be disabled, and must be two QTextLine not empty for enable the add button. I have the following code, but it does not works fine: void Question_Answer::on_newQuestion_txt_textChanged(const QString &arg1) { if(arg1.isEmpty()) { ui->addNewQuestion_btn->setEnabled(false);...

how to build Qt5 with qtwebkit on Windows with MSVC 2008 - leveldb can't find stdint.h

windows,build,qt5,leveldb,stdint
On a Windows 7 x64 box: I installed Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 I downloaded and unzipped Qt5.4.0 source from the "Source packages and Other releases" section of http://www.qt.io/download-open-source/# I built ICU 54.1 from source and installed it, per http://qt-project.org/wiki/Compiling-ICU-with-MSVC. I created a command...

QScintilla Font Combo Box Confliction

qt,qt4,qt5,qt5.4,qscintilla
I am using QScintilla in a Qt program of mine. I have a lexer set, so to change the font I have to change the font of the lexer. I have a font combo box so when I change the font it should change the font of the lexer. However,...

QT5: how to create .app bundle for macx

deployment,bundle,qt5,.app
I need to create a .app from my qt project for macx. I've create a simple sample project console, with CONFIG += app_bundle in .pro file then I used macdeployqt. When double click on .app, the application start to blinking in the mac bottom bar for at least 1 minute,...

Qt5, how to display stretched font (i.e. double width or double heigh)?

qt,fonts,qt5,stretch
i would like to represent on screen what a thermal printer prints like. The printer has special formatting and can print a font with double height or double width, so I have searched something but neither Html nor Rich Text seem to have an option to do this. I also...

Rotate QPixmap on a QGraphicsScene around a point

qt,qt5
My problem is the following: I have a QGraphicsScene, there is a QPixmap on it. I would like to rotate that pixmap around a center point, would work like a clock actually. I've tried these:í QPixmap pointer_pixmap("/home/peter/desktop/myimg2.png"); QTransform transform; QGraphicsPixmapItem *pointer = new QGraphicsPixmapItem(pointer_pixmap); pointer->setOffset(174,190); pointer->setTransformOriginPoint(QPoint(174-pointer_pixmap.width(), 190-pointer_pixmap.height()));...

Why Qt QML doesn't properly bind properties?

c++,qt,qml,qt5,qtquick2
It's very weird because I use almost the same pattern in another QML file and it works correctly! I'm sure I'm not reassigning value anywhere (the only thing I know that can make property static)! I have something like this (it's a simplified example and probably works as expected): Item...