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

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();
}

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.

where fcntl saves locking information

I wonder to understand where fcntl c++ function saves information about locked files. I know that it saves some information on /proc/locks , but fcntl identify lock even if it locked by another host
In my first host I locked some file By F_WRLCK.
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include<iostream>
main() {
int fd;
struct flock lock;
lock.l_type=F_WRLCK;
lock.l_start=0;
lock.l_whence= SEEK_SET;
lock.l_len=0;
printf("open %d\n",fd=open("/u/embedit/places/scratch/gtevos/ts16nxq42p11assrl16kaa03/ts16nxq42p11assrl16kaa.cpj", O_RDWR ));
int rc = fcntl(fd, F_SETLK, &lock);
std::cout<<rc<<std::endl;
std::cin>>fd;
}
When I am traying to lock the same file on my second host by F_RDONLY it doesn't work.
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include<iostream>
main() {
int fd;
struct flock lock;
lock.l_type=F_RDLCK;
lock.l_start=0;
lock.l_whence= SEEK_SET;
lock.l_len=0;
printf("open %d\n",fd=open("/u/embedit/places/scratch/gtevos/ts16nxq42p11assrl16kaa03/ts16nxq42p11assrl16kaa.cpj", O_RDONLY ));
int rc = fcntl(fd, F_SETLK, &lock);
std::cout<<rc<<std::endl;
std::cin>>fd;
}
I just want to understand which mechanism is used that provide ability to right identify locks.

getting CLOCK_TICK_RATE value in linux

I'm trying to print the value of CLOCK_TICK_RATE with the following program:
#include <fcntl.h>
#include <getopt.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <linux/kd.h>
#include <linux/timex.h>
int main() {
printf("%d\n",CLOCK_TICK_RATE);
}
I get an compilation error:
error: ‘CLOCK_TICK_RATE’ undeclared.
I looked for the definition of CLOCK_TICK_RATE, I found that in timex.h, but even after I included timex.h CLOCK_TICK_RATE is still undeclared.
thanks in advance.
Maybe you are looking for this?
#include <stdio.h>
#include <unistd.h>
int main (void) {
printf (
"%ld\n",
sysconf(_SC_CLK_TCK)
);
return 0;
}
It's in hertz and is normally 100.

how to write one entry in /var/run/utmp?

Based on this bug i'm trying to write an entry in /var/run/utmp to simulate the problem http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=528060 , i tryed with this code taken from manpages, but didn't work
#include <string.h>
#include <stdlib.h>
#include <pwd.h>
#include <unistd.h>
#include <utmp.h>
int
main(int argc, char *argv[])
{
struct utmp entry;
system("echo before adding entry:;who");
entry.ut_type = USER_PROCESS;
entry.ut_pid = getpid();
strcpy(entry.ut_line, ttyname(STDIN_FILENO) + strlen("/dev/"));
/* only correct for ptys named /dev/tty[pqr][0-9a-z] */
strcpy(entry.ut_id, ttyname(STDIN_FILENO) + strlen("/dev/tty"));
time(&entry.ut_time);
strcpy(entry.ut_user, getpwuid(getuid())->pw_name);
memset(entry.ut_host, 0, UT_HOSTSIZE);
entry.ut_addr = 0;
setutent();
pututline(&entry);
system("echo after adding entry:;who");
exit(EXIT_SUCCESS);
}
I solved my problem with this code
#include <string.h>
#include <stdlib.h>
#include <pwd.h>
#include <unistd.h>
#include <utmp.h>
int
main(int argc, char *argv[])
{
struct utmp entry;
system("echo before adding entry:;who");
entry.ut_type = USER_PROCESS;
entry.ut_pid = getpid();
strcpy(entry.ut_line, ttyname(STDIN_FILENO) + strlen("/dev/"));
/* only correct for ptys named /dev/tty[pqr][0-9a-z] */
strcpy(entry.ut_id, ttyname(STDIN_FILENO) + strlen("/dev/tty"));
time(&entry.ut_time);
//strcpy(entry.ut_user, getpwuid(getuid())->pw_name);
strcpy(entry.ut_user, "pippo");
memset(entry.ut_host, 0, UT_HOSTSIZE);
entry.ut_addr = 0;
setutent();
pututline(&entry);
system("echo after adding entry:;who");
exit(EXIT_SUCCESS);
}

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