Questions tagged [qtcore]

Questions related to the QtCore module that provides core non-graphical classes used by other modules.

If you use qmake to build your projects, Qt Core is included by default.

Official documentation.

Tagging recommendation:

Add this tag to questions when the issue at hand is related to the classes provided by this module. There are already several class tags for those, so you should add them, too.

The purpose of this is to provide a container for a better overview about the questions related to the core functionality.

Typically, this tag can be seen together with tags like , , , , , , , , , , et al.

371 questions
106
votes
10 answers

QString to char* conversion

I was trying to convert a QString to char* type by the following methods, but they don't seem to work. //QLineEdit *line=new QLineEdit();{just to describe what is line here} QString temp=line->text(); char *str=(char *)malloc(10); QByteArray…
mawia
  • 8,513
  • 13
  • 45
  • 57
90
votes
3 answers

Qt: *.pro vs *.pri

What is the difference between *.pro and *.pri configuration files for qmake? What should go into a *.pro file and what should go into a *.pri file?
Roman Byshko
  • 7,565
  • 5
  • 32
  • 54
50
votes
7 answers

How to find Version of Qt?

How do I know which version of Qt I am using? When I open Qt Creator it shows "Welcome to Qt Creator 2.3". In the build setting, however, it shows Qt Version 4.7.1.
user3472783
  • 523
  • 1
  • 5
  • 7
49
votes
7 answers

QByteArray to QString

I'm having issues with QByteArray and QString. I'm reading a file and stores its information in a QByteArray. The file is in unicode, so it contains something like: t\0 e\0 s\0 t\0 \0 \0 I'm trying to compare this value to my specified value, but it…
Nika
  • 1,694
  • 3
  • 21
  • 40
26
votes
1 answer

Does Q_UNUSED have any side effects?

Given the following piece of code: void test(int var) { Q_UNUSED(var); #ifdef SOMETHING printf("%d",var); //do something else with var... #endif } Would the Q_UNUSED macro have any effect if I actually use the 'var' variable in some…
Ilya Kobelevskiy
  • 4,987
  • 4
  • 20
  • 40
24
votes
2 answers

QString:number with maximum 2 decimal places without trailing zero

I have a division like this: number / 1000.0 Sometimes it gives answers like 96.0000000001, sometimes the division works as expected. I want to limit my number to a maximum of two decimal places and without trailing zeros. If it's 96.5500000001 it…
24
votes
8 answers

How to Compress Slot Calls When Using Queued Connection in Qt?

After reading some articles like this about Qt Signal-Slot communications I still have a question concerning the queued connection. If I have some threads sending signals all the time to each other and lets say one thread_slowis running a slow…
Michel Feinstein
  • 10,189
  • 11
  • 68
  • 144
23
votes
6 answers

Get system username in Qt

Is there any cross platform way to get the current username in a Qt C++ program? I've crawled the internet and the documentation for a solution, but the only thing I find are OS dependent system calls.
migas
  • 3,541
  • 3
  • 12
  • 15
22
votes
2 answers

Why QVector::size returns int?

std::vector::size() returns a size_type which is unsigned and usually the same as size_t, e.g. it is 8 bytes on 64bit platforms. In constrast, QVector::size() returns an int which is usually 4 bytes even on 64bit platforms, and at that it is signed,…
user3735658
22
votes
2 answers

Get relative path from a file in Qt

I am trying to get the relative path from files that I would like to write. Here a situation: I save a conf file in D:\confs\conf.txt. I have in my programs some files read from D:\images\image.bmp. In my conf.txt I would like to have…
user3627590
  • 271
  • 1
  • 4
  • 9
19
votes
4 answers

QFile doesn't recognize file:/// url path format

I get the file path from Qml like this: mainView.projectFilePath = Qt.resolvedUrl(newProjectFileDlg.fileUrl).toString(); The above file path looks like this: file:///C:/uuuu.a3 But when this path is passed to QFile, it complains The filename,…
Dean Chen
  • 3,464
  • 7
  • 38
  • 65
19
votes
1 answer

Convert const char* to QString

I have to use the output of a function of a type const char* and I need to convert it to QString. Note: inside that function, these are lines of code to return the const char* char* ClassA::getData() const{ return const_cast
Mahmoud Hassan
  • 572
  • 1
  • 3
  • 13
17
votes
9 answers

ImportError: cannot import name 'QtCore'

I am getting the below error with the following imports. It seems to be related to pandas import. I am unsure how to debug/solve this. Imports: import pandas as pd import numpy as np import pdb, math, pickle import matplotlib.pyplot as…
Abhishek Bhatia
  • 7,916
  • 14
  • 73
  • 134
16
votes
4 answers

No matching function for QObject::connect

I'm writing a program that send an UDP frame every 10 mS. Here's how my program is supposed to work : I've got a client class : //Constructor clientSupervision::clientSupervision() { } void clientSupervision::sendDataUDP(){ //Create a frame and…
Evans Belloeil
  • 2,233
  • 6
  • 37
  • 68
14
votes
2 answers

Parse jsonarray?

I've got an JSON like the following: { "agentsArray": [{ "ID": 570, "picture": "03803.png", "name": "Bob" }, { "ID": 571, "picture": "02103.png", "name": "Tina" }] } Now I'm trying to loop…
user3490755
  • 795
  • 2
  • 12
  • 29
1
2 3
24 25