Results 1 to 11 of 11

Thread: How can I make an object global?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I make an object global?

    Declare them outside of main() or put them in a header file
    but it is best not to use them where they can be avoided.

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3. #include "myglobals.h"
    4.  
    5. // globals here
    6. int aInteger;
    7.  
    8.  
    9. int main(int argc, char *argv[])
    10. {
    11. QApplication a(argc, argv);
    12. MainWindow w;
    13. w.show();
    14. return a.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by JD2000; 19th March 2010 at 13:59.

Similar Threads

  1. Getting std::string object from QString object ( qt3)
    By joseph in forum Qt Programming
    Replies: 11
    Last Post: 28th March 2013, 20:09
  2. Replies: 0
    Last Post: 15th November 2009, 09:40
  3. writing object to the file(Object Persistance)
    By jjbabu in forum Qt Programming
    Replies: 2
    Last Post: 11th June 2009, 14:28
  4. Open a QMainWindow Object in QDialog Object
    By chuengchuenghq in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2008, 06:33
  5. How to make an object blink in Qt?
    By thirupathiuppu007 in forum Qt Programming
    Replies: 2
    Last Post: 22nd February 2008, 10:30

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
  •  
Qt is a trademark of The Qt Company.