Results 1 to 2 of 2

Thread: QWidget: Must construct a QApplication before a QWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Windows Android

    Post QWidget: Must construct a QApplication before a QWidget

    Hi all:
    I've got this error in my application when I run in the release mode on Windows( on Ubuntu ,whether in debug or release mode ,there's no problem.And debug mode on Windows is ok). I think this error is related to a C++ library which I used in my application.In the library ,I build a class,which inherit from the QWidget class. And I build another class who is name is XXXmanger ,inherit from the QObject class to manage the widget class .When I try to new the manager class, the app goes wrong.

    Qt Code:
    1. CHistoryFormManager::CHistoryFormManager(QObject *parent) :
    2. CbaseFormManager(parent)
    3. {
    4. d_ptr = new CHistoryFormManagerPrivate;
    5. d_ptr->q_ptr = this;
    6. }
    To copy to clipboard, switch view to plain text mode 
    This is the construction function of the manager class .
    Qt Code:
    1. class CHistoryFormManagerPrivate
    2. {
    3. CHistoryFormManager * q_ptr;
    4. Q_DECLARE_PUBLIC(CHistoryFormManager)
    5.  
    6. public:
    7.  
    8. void addItem();
    9. void deleteItem();
    10. void openItem();
    11.  
    12. int m_index;
    13. QMenu *m_treeMenu;
    14. QMenu *m_itemMenu;
    15. QAction *m_addFormAction;
    16. QAction *m_deleteFormAction;
    17. QAction *m_openItemAction;
    18. QStandardItem *m_item;
    19. QWidget *m_widget;
    20. QTreeView *m_treePro;
    21.  
    22. QList<CHistoryForm *> m_formList;
    23. QList<QStandardItem *> m_newedItemList;
    24. QMap<QStandardItem*,CHistoryForm*> m_map;
    25.  
    26. private:
    27.  
    28. void createTreeMenu(QWidget * parent); // create tree Menu
    29. void createItemMenu(QWidget * parent); // create Item Menu
    30.  
    31. void createItemAction(QWidget * parent);
    32. void createTreeAction(QWidget * parent);
    33. };
    To copy to clipboard, switch view to plain text mode 

    This is the private class of the manager class.
    Please help. Thanks.
    Last edited by wysota; 27th October 2014 at 08:00. Reason: missing [code] tags

Similar Threads

  1. Replies: 16
    Last Post: 12th December 2014, 20:22
  2. Replies: 42
    Last Post: 25th July 2012, 21:39
  3. Replies: 2
    Last Post: 25th July 2011, 08:08
  4. Replies: 0
    Last Post: 20th April 2009, 17:45
  5. Must construct QApplication before QPaintDevice
    By sekatsim in forum Qt Programming
    Replies: 16
    Last Post: 8th June 2008, 00:00

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.