Questions tagged [qt5]
Questions specifically for version 5.x of the Qt library. If your question applies to other versions of Qt, use the tag [tag:qt4] or [tag:qt3]. It is recommended to use with the tag [tag:qt].
8,758
questions
168
votes
4
answers
80k
views
Connecting overloaded signals and slots in Qt 5
I'm having trouble getting to grips with the new signal/slot syntax (using pointer to member function) in Qt 5, as described in New Signal Slot Syntax. I tried changing this:
QObject::connect(spinBox,...
86
votes
7
answers
66k
views
Project ERROR: Unknown module(s) in QT: webkitwidgets
I am porting code from qt4 to qt5. I added the following line to my .pro file, as suggested:
QT += webkitwidgets
However, when I run qmake, I get the this error:
Project ERROR: Unknown module(s) in ...
74
votes
4
answers
139k
views
How to create/read/write JSON files in Qt5
Qt5 has a new JSON parser and I want to use it. The problem is that it isn't too clear about what the functions do in layman's terms and how to write code with it. That or I could be reading it wrong.
...
67
votes
3
answers
60k
views
Is there a tutorial specifically for PyQt5? [closed]
I am looking for a PyQt5 tutorial. It is rather complicated to start GUI development with Python for the first time without a tutorial.
I only found some PyQt4 tutorials so far, and since something ...
65
votes
4
answers
39k
views
Building Qt 5 on Linux, for Windows
I wanted to migrate my Qt 4 app to use Qt 5 instead. These instructions failed, due to some differences with how MXE builds Qt 5, including the fact that it uses modularised Qt tarballs, instead of ...
65
votes
4
answers
3k
views
How to generate video file from QImage sequence using QMediaRecorder in Qt5 C++
Basically what I want is to encode a video using QMediaRecorder by supplying as a source a sequence of QImages that I generate in custom code at run-time.
So far I have found no easy way to do this, ...
60
votes
2
answers
20k
views
Is there any difference between QRegularExpression and QRegExp?
I see there is a new class for regular expressions - QRegularExpression. Is it just a typedef for QRegExp, or a new class, or what? And why do we need it, we already have QRegExp?
58
votes
3
answers
32k
views
Qt Creator, ptrace: Operation not permitted. What is the permanent solution?
While debugging C++ code in Qt creator I get the following error
ptrace: Operation not permitted.
Could not attach to the process. Make sure no other debugger traces this process.
Check the settings ...
57
votes
1
answer
49k
views
QTextEdit vs QPlainTextEdit
What's the difference between QTextEdit and QPlainTextEdit, why use one over the other?
I'm coding a text editor as an exercice to learn Qt5, and now I'm wondering whether to use QTextEdit or ...
52
votes
6
answers
96k
views
How to find the Qt5 CMake module on Windows
I'm trying to make a very basic Qt5 application using CMake on Windows.
I used the documentation of Qt5 to use CMake, and my main.cpp file just contains a main function.
My CMakeLists.txt is exactly:
...
50
votes
5
answers
69k
views
Building Qt5 with Visual Studio 2012 / Visual Studio 2013, and integrating with the IDE
How do you get Qt5 to download and integrate with Visual Studio 2012? What are some of the problems you will encounter, and how do you solve those problems?
UPDATE re. Visual Studio 2013
Successes ...
50
votes
1
answer
900
views
Qt5 VideoOverview example does not work. Any solution?
I am stuck for a month with a video example given in Qt Video Overview.
I tried that code, but I only got a blank square (QWidget). I am using GStreamer0.10 for media playback over Qt5. I also played ...
46
votes
7
answers
94k
views
Dark theme for Qt widgets?
Background
I'm building a PyQt5 application, that I'd like to have a dark theme for. Previously I've worked with Android development where there was a dark theme that I could set for a whole ...
45
votes
8
answers
29k
views
Image rounded corners in QML
To my surprise, the Image component has no radius property. I tried emulating the rounded corners by putting the image in a rounded Rectangle, but it does not clip the corners.
Rectangle {
...
45
votes
4
answers
21k
views
Disconnecting lambda functions in Qt5
Is it possible to disconnect a lambda function? And if "yes", how?
According to https://qt-project.org/wiki/New_Signal_Slot_Syntax I need to use a QMetaObject::Connection which is returned from the ...
40
votes
5
answers
32k
views
Qt5. Embed QWidget object in QML
I am using Qt5 beta and trying to embed a QWidget-based object into QML. The goal is to use QML as much as possible, and only use QWidget objects where QML does not do what I need. I found a link ...
39
votes
4
answers
27k
views
How to update component in Qt 5.2.1+?
I see this message:
at least one valid and enable repository required for this action to
succeed
whenever I try to update components in Qt 5.2.1.
I know it is a reported bug (take a look here ...
39
votes
1
answer
34k
views
CMake cannot find Qt5LinguistTools in Docker / Ubuntu 18.04
My simple Dockerfile:
FROM ubuntu:18.04
RUN apt update && apt upgrade -y
RUN apt install build-essential cmake qt5-default -y
RUN apt install qttools5-dev-tools -y
When I check linguist ...
38
votes
12
answers
22k
views
Qt5 Target conditionals not found
I just updated to the latest version of command line tools in OS X Mavericks and now when compiling my (previously-working) code it throws the following error
> clang: warning: no such sysroot ...
38
votes
1
answer
22k
views
What is the difference between a QWindow and QWidget
The Qt 5.0 provides a new QWindow class. While the documentation on this class is quite comprehensive, I am failing to see how exactly the QWindow is different from the QWidget class, and in which ...
37
votes
2
answers
40k
views
What is the signal for when a widget loses focus?
In a dialog, when the tab key is pressed, the focus changes to another widget. In Qt, is there any signal for when a widget loses its focus? Can I use it to check if the input is valid or not? If not, ...
36
votes
6
answers
45k
views
Do I have to include all these Qt dlls with my application?
I'm totally new in using Qt and I don't know a lot of stuff.
As a test I created a simple application using Visual Studio 2012 and Qt-VS-Add-in based on the newest Qt5.1
After I compiled the ...
35
votes
6
answers
32k
views
QML: List all object members/properties in console
Is there any way to list all object members/properties in QML & Qt 5.1?
Such as:
var obj=myQObject;
console.log(obj)
// expected output:
// obj { x:123..... }
This would be very helpful for ...
35
votes
5
answers
53k
views
Get HWND on windows with Qt5 (from WId)
I am trying to convert a Qt4 Application to Qt5.
The only thing I couldn't figure out is how to get the HWND of a Widget.
The program uses EcWin7 to show the progress on the taskbar icon on win 7+ but ...
33
votes
10
answers
87k
views
Qt5 Static Build yields Failed to load platform plugin "windows"
I am writing a Qt application on Windows using Visual Studio 2012.
Using the Qt Add-in and a custom built static distribution of Qt 5.0.2.
I am running into the dreaded "Failed to load platform ...
33
votes
5
answers
53k
views
Qt5 QML module is not installed
I'm confused about modules in Qt QML. I've read all the docs, but it doesn't make clear some basic ideas.
I understand that i can put a bunch of QML files into a directory and add a qmldir file to ...
33
votes
1
answer
21k
views
Range slider in Qt (two handles in a QSlider)
I need a range selection using QSlider. Is it possible to get two handles, if not, is there any piece of code available to handle that smartly?
Below is an image illustrating what I need.
32
votes
9
answers
40k
views
Accessing C++ QLists from QML
If I've got a list of things in C++, how do I expose that to QML (in Qt5 / QtQuick 2)? It seems like QML can only understand QObject-derived classes, which is an issue because QObjects can't be put in ...
32
votes
8
answers
28k
views
Application deployed with QT5 libraries does not start on Windows 7
Recently we have been migrating our QT based application on Windows from QT 4.8 to QT 5, and we have run into a issue with deployment. Note that our app has not changed, we have only built it with new ...
32
votes
4
answers
70k
views
How do I use Qt in my Visual Studio 2015 projects?
We have large project that used .NET Framework for showing forms/windows. Recently I decided to deprecate CLR dependency and move to Qt.
While learning Qt, we've migrated from Visual studio 2013 to ...
32
votes
2
answers
23k
views
C++ Qt where's the std::unique_ptr Qt version?
So when programming in Qt I like to go with the Qt implementation as far as possible.
As far as I've seen there's no Qt version of the std::unique_ptr or is there?
What would be the alternatives that ...
32
votes
3
answers
37k
views
QWebView or QWebEngineView
Are there any functional differences between QWebView and QWebEngineView? If I understand correctly, QWebView is webkit, while QWebEngineView is blink. Are there any differences to the programmer? ...
31
votes
7
answers
97k
views
CMAKE_PREFIX_PATH doesn't help CMake in finding Qt5
From here: https://stackoverflow.com/a/28327499/462608
I tried this:
cmake_minimum_required(VERSION 2.8.12)
project(qtquick_hello_cmake)
set(CMAKE_PREFIX_PATH "/opt/Qt5.9.1/5.9.1/")
set(...
31
votes
2
answers
45k
views
Remove selected items from listWidget
How to remove selected items from a QListWidget?
I have tried write the following code, but it does not work.
QList<QListWidgetItem*> items = ui->listWidget->selectedItems();
foreach(...
30
votes
4
answers
41k
views
No default repositories in Qt Maintenance Tool
I recently installed Qt 5.5 and its MaintenanceTool (MaintenanceTool.exe). The default repositories were working, but after one day, my MaintenanceTool suddenly reported that no repositories were set.
...
30
votes
2
answers
21k
views
How to specify Mac platform in qmake (QtCreator)
I would like to set some configurations for Mac OS in pro file via QtCreator. I read the document, and found it supports Windows and Unix, like the following,
win32 {
SOURCES += hellowin.cpp
}...
30
votes
4
answers
18k
views
How to include child mouse hover events in the parent MouseArea using QML?
I want to implement the following scenario in QML.
Here is a sample/simplified delegate for ListView element:
Component {
Item {
id: container
MouseArea {
anchors....
28
votes
2
answers
28k
views
How to insert QChartView in form with Qt Designer?
I want to add QChart to the form. But I can't find it in the Widget Box. So I created it in the code. How can I insert it in QWidget or QFrame or something else?
I want to set area of that widget ...
28
votes
4
answers
29k
views
How to check the selected version of Qt in a .pro file?
I have multiple versions of Qt installed, and I need to compile my project with all of them.
Using a pro file, I could not find in the documentation how to do a conditional compilation.
Ideally, ...
28
votes
3
answers
44k
views
How to catch exceptions in Qt?
try
{ // `count()` throws exception
connect(thread, SIGNAL(started()), engine, SLOT(count()));
}
catch(const X& e)
{}
As of Qt-5, I get following error:
Qt has caught an exception thrown ...
27
votes
2
answers
12k
views
How to override just one property:value pair in Qt StyleSheet
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:
...
26
votes
1
answer
2k
views
Why does FlowLayout behave differently in Qt 5.2, compared to Qt 4.8?
I've just ported my application from Qt 4.8.4 to Qt 5.2.1. I have an issue with the FlowLayout class as provided in the FlowLayout example code in the Qt docs.
I have a QMainWindow with a QDockWidget ...
25
votes
7
answers
115k
views
Qt5 - setting background color to QPushButton and QCheckBox
I'm trying to change the background color of a QAbstractButton (either a QPushButton or QCheckBox) in Qt5 and having zero luck.
This does nothing:
pButton->setAutoFillBackground(true);
QPalette ...
25
votes
4
answers
23k
views
Qt 5 build error: extra characters after test expression
I am trying to learn Qt 5.3, and this is my first program (hello world). When I try to build, it displays this error:
extra characters after test expression.
I cannot understand at all why this ...
25
votes
3
answers
15k
views
Deploying Qt5 on Windows without Hardware Acceleration
Qt5 can use the OpenGL driver or the DirectX Driver by using ANGLE. As we cannot depend on an installed OpenGL driver, we need to use the ANGLE backend. Unfortunately, this doesn't solve all ...
24
votes
8
answers
15k
views
QList vs QVector revisited
My question is basically when to choose QVector and when to choose QList as your Qt container. What I already know:
Qt docs: QList class
For most purposes, QList is the right class to use. Its ...
24
votes
3
answers
36k
views
What is the use of various Qt platform plugins?
I was doing some cross compiling of a Qt5.2 application for an ARM based target (TI AM335x EVM) and it was failing to display anything on my platform. After doing some google’ing I found that if I ...
24
votes
4
answers
33k
views
How to declare list property in QML
How do I declare a list property in QML (for use with Qt.labs.settings in my case):
Settings {
property list recentFiles: []
}
Does not work. I've tried many other options: list<string>, ...
24
votes
1
answer
14k
views
In Qt 5, what's the right way to show multi-monitor full screen QWidget windows?
I have a Windows & Mac program that switches into full-screen mode on multiple monitors. In Qt 4, it seems (I can't find explicit documentation on how to do this) like the 'correct' way to go ...
24
votes
1
answer
5k
views
Qt5 new signal to lambda connections memory leak
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 (...