Results 1 to 5 of 5

Thread: can't new qwebview in a mainwindow constructor

  1. #1
    Join Date
    Aug 2006
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Angry can't new qwebview in a mainwindow constructor

    hi,

    i want to new a qwebview instance like this inside the constructor of the mainwindow class

    view=new QWebView(this);

    the code compiles. but the program exits automatically saying "

    Qwidget: must construct a QApplication before a QPaintDevice

    "

    i tried to use the qtdesigner to generate a mainwindow with a webview. and that one has the same problem.

    what happened? how to fix it?

    thank you very much.

  2. #2
    Join Date
    Oct 2007
    Location
    Grenoble, France
    Posts
    80
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: can't new qwebview in a mainwindow constructor

    Qwidget: must construct a QApplication before a QPaintDevice
    Your answer is here. You have to construct QApplication first.
    Normally your main.cpp should look somehow like that:
    Qt Code:
    1. #include <QtGui/QApplication>
    2.  
    3. #include "mainwindow.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8. MainWindow w;
    9. w.show();
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    You can try to use QtCreator to start a new project - this code will be generated automatically.

    Next time in your posts please use correct tags (quote, code etc.) and write in a proper forum (this post should be in newbie forum).
    Last edited by calhal; 15th July 2009 at 00:52. Reason: updated contents
    You have to run a level 3 diagnostic.

    Ashes to ashes, Qt to Qt ( wysota )

  3. #3
    Join Date
    Aug 2006
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Re: can't new qwebview in a mainwindow constructor

    thank you for your reply,

    but i don't quite understand, because i did construct a QApplication first.

    this is my main.cpp

    Qt Code:
    1. #include "MainWindow.h"
    2.  
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7. MainWindow mainWindow;
    8. mainWindow.showFullScreen();
    9. //mainWindow.prepare();
    10. return app.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 



    i have used qt for a while, i'm not completely new to qt, but this is the first time i have the problem. thanks.
    Last edited by wysota; 15th July 2009 at 10:28. Reason: Changed [quote] to [code]

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: can't new qwebview in a mainwindow constructor

    can you produce a minimal compilable program reproducing the problem?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: can't new qwebview in a mainwindow constructor

    Make sure you don't have any globals or statics that are paint devices (pixmaps, widgets, etc.).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 6
    Last Post: 8th July 2009, 21:28
  2. mainwindow modality
    By user in forum Qt Programming
    Replies: 0
    Last Post: 11th July 2008, 01:54
  3. Notifying Mainwindow of an event..
    By MrGarbage in forum Qt Programming
    Replies: 1
    Last Post: 9th November 2007, 22:29
  4. Replies: 1
    Last Post: 11th September 2007, 14:34
  5. Replies: 3
    Last Post: 23rd July 2006, 19:02

Tags for this Thread

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.