Results 1 to 2 of 2

Thread: doubts regarding QT

  1. #1
    Join Date
    Aug 2008
    Posts
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default doubts regarding QT

    Hi every body ,I am having some doubts regarding QT

    Q. If i create two objects of QApplication what will happen? Why shouldn't i use two?

    Q.In Gui application I created on mainwindow and excuted in main.cpp .Then which one is parent I mean QApplication or Mainwindow.

    So please help me.

    regards,
    sudheer.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: doubts regarding QT

    Quote Originally Posted by sudheer168 View Post
    Q. If i create two objects of QApplication what will happen? Why shouldn't i use two?
    I cannot think what you could hope to achieve by doing this. From the docs:
    For any GUI application using Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time. For non-GUI Qt applications, use QCoreApplication instead, as it does not depend on the QtGui library.
    Attempting to allocate a second instance will probably just return a pointer to the existing one. If you really want to know what will happen then try it.
    Quote Originally Posted by sudheer168 View Post
    Q.In Gui application I created on mainwindow and excuted in main.cpp .Then which one is parent I mean QApplication or Mainwindow.
    Parent of what?

    The QMainWindow will not have a QWidget parentWidget(), but may have a QObject parent() depending on how the object was created. The QMainWindow will be the parentWidget() of its central widget, and may be the parent() to QObjects (its subordinate widgets and possibly other stuff).

    The QApplication object exists to provide a lot of event handling and general set up/tear down facilities for the application as a whole. It may be the parent to QObjects (including your QMainWindow). It is not a parent in the GUI widget hierarchy... it's not a QWidget.

Similar Threads

  1. Some critical "QtWebKit" doubts
    By crazymoonboy in forum Newbie
    Replies: 1
    Last Post: 18th September 2008, 23:56
  2. Touch screen and QT embedded, some doubts
    By webquinty in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 30th June 2008, 10:59
  3. Please Help-->have few doubts with Static build in Windows !
    By Krish in forum Installation and Deployment
    Replies: 1
    Last Post: 17th March 2008, 14:37
  4. typedef Related doubts?
    By rajeshs in forum General Programming
    Replies: 3
    Last Post: 2nd January 2008, 19:05
  5. Replies: 2
    Last Post: 28th January 2006, 14:33

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.