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
Code:
#include "hellotest.h" HelloTest :: HelloTest(QWindow *parent): QWindow(parent) { 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); 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() { }
hellotest.h
Code:
#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
main.cpp
Code:
#include "hellotest.h" //QX11EmbedWidget *embed; QWindow *embed; //QWidget * embed; HelloTest *hellotest; int main(int argc, char *argv[]) { //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(); }