Results 1 to 5 of 5

Thread: example using Qwindow

  1. #1
    Join Date
    Mar 2013
    Location
    Hyderabad,Bangalore,India
    Posts
    70
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default example using Qwindow

    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
    Qt Code:
    1. #include "hellotest.h"
    2.  
    3. HelloTest :: HelloTest(QWindow *parent):
    4. QWindow(parent)
    5.  
    6. {
    7. QWidget *cont = new QWidget;
    8. qDebug() << "in hello test";
    9. //QWidget *window = new QWidget(parent);
    10. //QProcess *process = new QProcess(this);
    11. //args<<"-style"<<"fusion";
    12. //process->start("../../sample-build-Qt5_1Alpha-Debug/sample");//,args);
    13.  
    14. QWidget *window = new QWidget ;//::createWindowContainer(this,0,0);
    15. window -> resize(500,500);
    16. window ->setPalette(QPalette(QColor(255,0,0,255)));
    17. //setIcon(QIcon("/home/ramu/Pictures/screen.png"));
    18. //window -> setPalette(QPalette(QColor(0,255,0,255)));
    19. //window -> setAutoFillBackground(true);
    20. cont -> setLayout(vl);
    21. vl -> addWidget(window);
    22. }
    23.  
    24. HelloTest::~HelloTest()
    25. {
    26.  
    27. }
    To copy to clipboard, switch view to plain text mode 

    hellotest.h

    Qt Code:
    1. #ifndef HELLOTEST_H
    2. #define HELLOTEST_H
    3.  
    4. #include <QtWidgets/QWidget>
    5. #include <QDebug>
    6. #include <QtX11Extras/qx11info_x11.h>
    7. #include <QtWidgets/QApplication>
    8. #include <QtWidgets/QVBoxLayout>
    9. #include <QWindow>
    10. #include<QProcess>
    11.  
    12. class HelloTest :public QWindow
    13. {
    14. Q_OBJECT
    15.  
    16. public:
    17. HelloTest(QWindow *parent = 0);
    18. ~HelloTest();
    19. private:
    20.  
    21.  
    22.  
    23. };
    24.  
    25. #endif // HELLOTEST_H
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include "hellotest.h"
    2. //QX11EmbedWidget *embed;
    3. QWindow *embed;
    4. //QWidget * embed;
    5. HelloTest *hellotest;
    6.  
    7. int main(int argc, char *argv[])
    8. {
    9. QApplication qapp(argc, argv);
    10. QString windowId(qapp.arguments()[1]);
    11. QVBoxLayout* layout = new QVBoxLayout;
    12.  
    13. //embed = new QWidget;
    14. embed = new QWindow;
    15. // embed -> setMinimumSize(500,500);
    16. embed -> resize(500,500);
    17. // embed ->setIcon(QIcon("/home/Pictures/screen.png"));
    18. //embed -> setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    19.  
    20. //embed -> setPalette(QColor(255,0,0,255));
    21.  
    22. //embed -> setAutoFillBackground(true);
    23.  
    24. hellotest = new HelloTest(embed);
    25. //hellotest -> setContentsMargins(0,0,0,0);
    26.  
    27. if(NULL == embed)
    28. {
    29. qDebug() << "Unable to create hellotest";
    30. return 0;
    31. }
    32. if(argc < 2)
    33. {
    34. qDebug() << "More Arguments Needed";
    35. return 0;
    36. }
    37. qDebug()<<"windowId in WG:"<<windowId;
    38.  
    39. //layout -> addWidget(hellotest);
    40. //embed -> setLayout(layout);
    41. // embed -> embedInto(windowId.toULong());
    42. // embed ->fromWinId(windowId.toULong());
    43. // embed -> setVisible(true);
    44. embed -> show();
    45. return qapp.exec();
    46. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: example using Qwindow

    You are creating widgets but not showing them.

    Cheers,
    _

  3. #3
    Join Date
    Mar 2013
    Location
    Hyderabad,Bangalore,India
    Posts
    70
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: example using Qwindow

    Hi anda_skoa
    i am in the process of converting my Qt4 related code to Qt5 in below thread.

    can you please look at it and guide me .

    thanks

    http://www.qtcentre.org/threads/5492...d-embedwidgets

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: example using Qwindow

    Ah.

    I think in both applications you would just use normal QWidgets.
    In the one that is the container you create a window using fromWinId() and embed that into your widget using createWindowContainer.

    Haven't tried that myself yet, but that is how I would approach it.

    Cheers,
    _

  5. #5
    Join Date
    Mar 2013
    Location
    Hyderabad,Bangalore,India
    Posts
    70
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: example using Qwindow

    Hi anda_skoa,

    I have update with the new code.

    if possible have a look and let me know if you have any points.

    http://www.qtcentre.org/threads/5492...934#post245934

    Thanks,

Similar Threads

  1. QWindow does not hav getOpacity function?
    By awfan in forum Qt Programming
    Replies: 3
    Last Post: 23rd January 2013, 10:28
  2. Replies: 2
    Last Post: 18th August 2011, 07:26
  3. Why QWindow is not initialized with the NEW keyword?
    By probine in forum Qt Programming
    Replies: 5
    Last Post: 3rd April 2010, 22:28
  4. Parenting QWindow...
    By roomie in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2006, 09:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.