qt thread file not found - multithreading

fatal error: 'thread' file not found
this is main.cpp.
#include <QApplication>
#include <QMainWindow>
#include <thread>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow w;
w.show();
return a.exec();
}
this is pro file.
QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = empty
TEMPLATE = app
DEFINES += CC_TARGET_QT5
CONFIG += c++11
SOURCES += main.cpp
a strange question. why ?

Related

error:argument type 'xx' is incomplete for hiding call to ptrace example code

I'm testing an antidebug solution with ptrace method; and i compile the program by using ndk21e cross-compile.
The problem is that it compiles successfully with gcc, but fails with ndk cross-compile.
ndk cross-compile compiles all other programs without problems
#include <stdlib.h>
#include <stdio.h>
#include<sys/ptrace.h>
#include <dlfcn.h>
#include <string.h>
int main(int argc, char **argv) {
void *handle;
long (*go)(enum __ptrace_request request, pid_t pid);
// get a handle to the library that contains 'ptrace'
handle = dlopen ("/lib/x86_64-linux-gnu/libc.so.6", RTLD_LAZY);
// reference to the dynamically-resolved function 'ptrace'
go = dlsym(handle, "ptrace");
if (go(PTRACE_TRACEME, 0) < 0) {
puts("being traced");
exit(1);
}
puts("not being traced");
// cleanup
dlclose(handle);
return 0;
}
And it shows the error like the picture as follow:
gcc compileresult and cross-compile error result
How can i solve this problem. Thanks.

How to fix QDialog transparent background afterimage issue in qt embedded (QT4.7.3)?

I am using embedded system and I'm testing transparent QWS server where is my Qt4.7.3.
I faced the afterimage in the QDialog when moving cursor in test program which as the QWS client, but it didn't happen in the QMainWindow which in QWS server program.
Can anyone help me to fix the issue?
There is the issue
Here is test program source code.
#include "mainwindow.h"
#include <QApplication>
#include<QWSServer>
#include <QDialog>
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#include "qscreenlinuxfb_qws.h"
#include "qscreendriverfactory_qws.h"
#include <errno.h>
extern "C" {
extern int Test();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QDialog w;
QWSServer::setBackground(QColor(0,0,0,0));
QWSServer::setCursorVisible(false);
w.setStyleSheet("background-color:transparent;");
w.show();
return a.exec();
}
OK I found the issue. In QT source code.
src\gui\embedded\qscreen_qws.cpp
if (!blendSize.isNull()) {
*blendbuffer = new QImage(blendSize, d_ptr->preferredImageFormat());
}
to
if (!blendSize.isNull()) {
*blendbuffer = new QImage(blendSize, d_ptr->preferredImageFormat());
QPixmap temp = QPixmap(blendSize);
temp.fill(Qt::transparent);
**blendbuffer = temp.toImage();
}

Pthreads and QT

I have a issue, where I need the GUI from QT Designer to give values to a separate program running from terminal where the values from the GUI are "printed" onto the terminal interface (Linux with GCC compiler)
I have researched pthreads, but their application examples are limited to In-Application uses. The code in my main file is as follows:
#include "main_window.h"
#include <QApplication>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
void *thr_func(void *thread_id)
{
int tid = thread_id;
pthread_mutex_lock(&lock_x);
cout << "thread" << tid << end1;
cout << xValue << end1;
cout << yValue << end1;
cout << zValue << end1;
pthread_mutex_unlock(&lock_x);
}
int main(int argc, char *argv[])
{
pthread_create(thread_1, NULL, thr_func, NULL)
while(true)
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
pthread_exit(NULL);
}
**Note that xValue, yValue, and zValue already stream to a textfile from the QT application. I am adapting the application for terminal running and control.

EGLFS QML Screen not rotated

I have Debian Bullseye, Intel Celeron J1800 with integrated graphics. Qt from Debian version 5.12.5
Trying to rotate screen to portrait mode.
QT_QPA_EGLFS_ROTATION=90 /opt/app/bin/app
But window just resized, scaled up about 120%.
My code
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.addImportPath("qrc:/");
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
}
And QML
ApplicationWindow {
id: window
visible: true
flags: Qt.FramelessWindowHint
StackView { ... }
}
QWebEngineView and widgets works well
Seems works
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QMainWindow>
#include <QVBoxLayout>
#include <QQuickWidget>
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
QApplication app(argc, argv);
const QUrl url(QStringLiteral("qrc:/main.qml"));
QQuickWidget *w = new QQuickWidget;
w->resize(400,300);
w->setResizeMode(QQuickWidget::SizeRootObjectToView );
w->engine()->addImportPath("qrc:/");
w->setSource(url);
w->showFullScreen();
return app.exec();
}
and qml
Rectangle {
id: window
visible: true
StackView { ... }
}

Wrong size in Qt widget + widget updage issue

Here is a pruned version of a problem I have using QT/linux. The program runs, but the size of the displayed widget is wrong (the contents, frame + labels, does not fit).
I understood that the size of a windows should be computed fron its contents (children). Why is that not happening properly here?
So the first question is, of course why this is happening.
The real program actually updates the contents of the widget at run-time. I have tried to simulate that behavior by the insertion of the main_window->show() (commented //SHOW1). If this first show() call is made, then the second show() does not show the new contents the widget. I have tried with update without success...
#include <QApplication>
#include <QtCore>
#include <QMainWindow>
#include <QTabWidget>
#include <QWidget>
#include <QGroupBox>
#include <QVBoxLayout>
#include <QLabel>
#include <stdlib.h>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow* main_window = new(QMainWindow);
main_window->setObjectName("main_window");
main_window->resize(800, 600);
main_window->setWindowTitle("Hello");
QTabWidget* node_tab_widget = new QTabWidget(main_window);
// node_tab_widget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
// node_tab_widget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
node_tab_widget->setObjectName(QString::fromUtf8("tab_widget"));
node_tab_widget->resize(500, 400);
QWidget* w= new QWidget(node_tab_widget);
node_tab_widget->addTab(w, "TAB");
//main_window->show(); //SHOW1
QGroupBox* group_widget = new QGroupBox("GROUPNAME", w);
QVBoxLayout* group_layout = new QVBoxLayout;
group_widget->setLayout(group_layout);
group_layout->addWidget((QLabel*)new QLabel(">>>>>>>>>>>>>>>>>>>>>>>>>here1"));
group_layout->addWidget((QLabel*)new QLabel("here2"));
// group_widget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
main_window->update();
main_window->show();
return app.exec();
}
I don't really understand what is the result you expect, can be something like what you get from this code:
#include <QApplication>
#include <QtCore>
#include <QMainWindow>
#include <QTabWidget>
#include <QWidget>
#include <QGroupBox>
#include <QVBoxLayout>
#include <QLabel>
#include <stdlib.h>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QMainWindow* main_window = new(QMainWindow);
main_window->setObjectName("main_window");
main_window->resize(800, 600);
main_window->setWindowTitle("Hello");
QTabWidget* node_tab_widget = new QTabWidget();
node_tab_widget->setObjectName(QString::fromUtf8("tab_widget"));
node_tab_widget->resize(500, 400);
QWidget* w= new QWidget();
node_tab_widget->addTab(w, "TAB");
QGroupBox* group_widget = new QGroupBox("GROUPNAME", w);
QVBoxLayout* group_layout = new QVBoxLayout;
group_widget->setLayout(group_layout);
group_layout->addWidget((QLabel*)new QLabel(">>>>>>>>>>>>>>>>>>>>>>>>>here1"));
group_layout->addWidget((QLabel*)new QLabel("here2"));
QVBoxLayout* gl = new QVBoxLayout;
gl->addWidget(group_widget);
main_window->setCentralWidget(node_tab_widget);
main_window->show();
return app.exec();
}
which add the QTabWidget node_tab_widget as central widget, with a tab TAB.
The tab contain the QGroupBox GROUPNAME with the two labels (vertical aligned)

Resources