Hi,
i have written a sample program using Qwindow.
i would like to set some color or add some image to QWindow, but as soon as i run the program the window is opening with background color of other below windows , in my case i m opening from qtcreator,so the window is opening with qtcrator background.
hellotest.cpp
#include "hellotest.h"
HelloTest :: HelloTest(QWindow *parent):
QWindow(parent)
{
qDebug() << "in hello test";
//QWidget *window = new QWidget(parent);
//QProcess *process = new QProcess(this);
//args<<"-style"<<"fusion";
//process->start("../../sample-build-Qt5_1Alpha-Debug/sample");//,args);
window -> resize(500,500);
//setIcon(QIcon("/home/ramu/Pictures/screen.png"));
//window -> setPalette(QPalette(QColor(0,255,0,255)));
//window -> setAutoFillBackground(true);
cont -> setLayout(vl);
vl -> addWidget(window);
}
HelloTest::~HelloTest()
{
}
#include "hellotest.h"
HelloTest :: HelloTest(QWindow *parent):
QWindow(parent)
{
QWidget *cont = new QWidget;
QVBoxLayout *vl = new QVBoxLayout;
qDebug() << "in hello test";
//QWidget *window = new QWidget(parent);
//QProcess *process = new QProcess(this);
QStringList args;
//args<<"-style"<<"fusion";
//process->start("../../sample-build-Qt5_1Alpha-Debug/sample");//,args);
QWidget *window = new QWidget ;//::createWindowContainer(this,0,0);
window -> resize(500,500);
window ->setPalette(QPalette(QColor(255,0,0,255)));
//setIcon(QIcon("/home/ramu/Pictures/screen.png"));
//window -> setPalette(QPalette(QColor(0,255,0,255)));
//window -> setAutoFillBackground(true);
cont -> setLayout(vl);
vl -> addWidget(window);
}
HelloTest::~HelloTest()
{
}
To copy to clipboard, switch view to plain text mode
hellotest.h
#ifndef HELLOTEST_H
#define HELLOTEST_H
#include <QtWidgets/QWidget>
#include <QDebug>
#include <QtX11Extras/qx11info_x11.h>
#include <QtWidgets/QApplication>
#include <QtWidgets/QVBoxLayout>
#include <QWindow>
#include<QProcess>
class HelloTest :public QWindow
{
Q_OBJECT
public:
HelloTest(QWindow *parent = 0);
~HelloTest();
private:
};
#endif // HELLOTEST_H
#ifndef HELLOTEST_H
#define HELLOTEST_H
#include <QtWidgets/QWidget>
#include <QDebug>
#include <QtX11Extras/qx11info_x11.h>
#include <QtWidgets/QApplication>
#include <QtWidgets/QVBoxLayout>
#include <QWindow>
#include<QProcess>
class HelloTest :public QWindow
{
Q_OBJECT
public:
HelloTest(QWindow *parent = 0);
~HelloTest();
private:
};
#endif // HELLOTEST_H
To copy to clipboard, switch view to plain text mode
main.cpp
#include "hellotest.h"
//QX11EmbedWidget *embed;
QWindow *embed;
//QWidget * embed;
HelloTest *hellotest;
int main(int argc, char *argv[])
{
QString windowId
(qapp.
arguments()[1]);
//embed = new QWidget;
embed = new QWindow;
// embed -> setMinimumSize(500,500);
embed -> resize(500,500);
// embed ->setIcon(QIcon("/home/Pictures/screen.png"));
//embed -> setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
//embed -> setPalette(QColor(255,0,0,255));
//embed -> setAutoFillBackground(true);
hellotest = new HelloTest(embed);
//hellotest -> setContentsMargins(0,0,0,0);
if(NULL == embed)
{
qDebug() << "Unable to create hellotest";
return 0;
}
if(argc < 2)
{
qDebug() << "More Arguments Needed";
return 0;
}
qDebug()<<"windowId in WG:"<<windowId;
//layout -> addWidget(hellotest);
//embed -> setLayout(layout);
// embed -> embedInto(windowId.toULong());
// embed ->fromWinId(windowId.toULong());
// embed -> setVisible(true);
embed -> show();
return qapp.exec();
}
#include "hellotest.h"
//QX11EmbedWidget *embed;
QWindow *embed;
//QWidget * embed;
HelloTest *hellotest;
int main(int argc, char *argv[])
{
QApplication qapp(argc, argv);
QString windowId(qapp.arguments()[1]);
QVBoxLayout* layout = new QVBoxLayout;
//embed = new QWidget;
embed = new QWindow;
// embed -> setMinimumSize(500,500);
embed -> resize(500,500);
// embed ->setIcon(QIcon("/home/Pictures/screen.png"));
//embed -> setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
//embed -> setPalette(QColor(255,0,0,255));
//embed -> setAutoFillBackground(true);
hellotest = new HelloTest(embed);
//hellotest -> setContentsMargins(0,0,0,0);
if(NULL == embed)
{
qDebug() << "Unable to create hellotest";
return 0;
}
if(argc < 2)
{
qDebug() << "More Arguments Needed";
return 0;
}
qDebug()<<"windowId in WG:"<<windowId;
//layout -> addWidget(hellotest);
//embed -> setLayout(layout);
// embed -> embedInto(windowId.toULong());
// embed ->fromWinId(windowId.toULong());
// embed -> setVisible(true);
embed -> show();
return qapp.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks