Results 1 to 1 of 1

Thread: QWebView,QWidget,createWindowContainer,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 QWebView,QWidget,createWindowContainer,QWindow

    Hi,

    I am trying to add a WebView to QWidget got from createWindowContainer which in turn used QWindow.

    But it does not show the page.It displays only window with text "QWindow" in it.


    Qt Code:
    1. QWidget * display = new QWidget;
    2. QWidget * window ;
    3.  
    4. void MainWindow::launch_app(int id)
    5. {
    6. WId winid = (WId) id;
    7. qDebug()<<"In launch_app win id is "<< id;
    8. display->setLayout(vl);
    9. window = createWindowContainer(QWindow::fromWinId(winid),display,\
    10. Qt::WindowMinMaxButtonsHint|Qt::WindowCloseButtonHint
    11. |Qt::WindowCancelButtonHint
    12. |Qt::FramelessWindowHint);
    13.  
    14.  
    15. QUrl qurl("http://google.com");
    16. QHBoxLayout *layout2 = new QHBoxLayout;
    17. QWebView *m_WebView = new QWebView;
    18. window->setLayout(layout2);
    19. layout2->addWidget(m_WebView);
    20. m_WebView->setFocusPolicy(Qt::StrongFocus);
    21.  
    22. m_WebView->load(qurl);
    23. m_WebView->show();
    24. vl -> addWidget(window);
    25. qDebug()<<"addWidget";
    26. }
    To copy to clipboard, switch view to plain text mode 

    the winid is got from below window having below structure

    Qt Code:
    1. class RasterWindow : public QWindow
    2. {
    3. Q_OBJECT
    4. public:
    5. explicit RasterWindow(QWindow *parent = 0);
    6.  
    7. virtual void render(QPainter *painter);
    8.  
    9. public slots:
    10. void renderLater();
    11. void renderNow();
    12.  
    13. protected:
    14. bool event(QEvent *event);
    15.  
    16. void resizeEvent(QResizeEvent *event);
    17. void exposeEvent(QExposeEvent *event);
    18.  
    19. private:
    20. QBackingStore *m_backingStore;
    21. bool m_update_pending;
    22. };
    23.  
    24. void RasterWindow::render(QPainter *painter)
    25. {
    26. painter->drawText(QRectF(0, 0, width(), height()), Qt::AlignCenter, QStringLiteral("QWindow"));
    27. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

Similar Threads

  1. Error in CreateWindowContainer in Qt5.1.0
    By alizadeh91 in forum Qt Programming
    Replies: 12
    Last Post: 17th September 2013, 20:15
  2. Replies: 8
    Last Post: 3rd September 2013, 10:51
  3. example using Qwindow
    By PstdEr in forum Qt Programming
    Replies: 4
    Last Post: 14th June 2013, 14:31
  4. Replies: 2
    Last Post: 18th August 2011, 08:26
  5. Parenting QWindow...
    By roomie in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2006, 10: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.