Results 1 to 2 of 2

Thread: QT and variable scope

  1. #1
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QT and variable scope

    I have a question that is borderline between Qt and C++.
    The program I'm writing consists of many functions distributed between several *.cpp files. Many functions act on the same variables (about 10 total) and there is no reason to hide any variables from any of the functions (all can be public).
    Which of the following is the best way to make all variables available to the relevant functions? By best I mean - which is the fastest?

    a) Declare all under "public" in the single QWidget class that I use
    b) Use variable passing between functions as needed
    c) Give all variables global scope by declaring them outside of all functions

  2. #2
    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: QT and variable scope

    There is no borderline - everything that applies to C++, applies to Qt. Use whatever means you would have used in pure C++ application.

Similar Threads

  1. System environment variable
    By fahlen in forum Qt Programming
    Replies: 4
    Last Post: 27th November 2007, 19:02
  2. Qtopia core 4.2.2 cross compile make error
    By smiyai18 in forum Installation and Deployment
    Replies: 2
    Last Post: 28th August 2007, 17:04
  3. Variable question
    By MarkoSan in forum General Programming
    Replies: 4
    Last Post: 15th March 2007, 14:59
  4. saving a c string of variable length in a shared memory?
    By nass in forum General Programming
    Replies: 4
    Last Post: 3rd January 2007, 14:40
  5. custom plugin designer property with out a variable?
    By high_flyer in forum Qt Programming
    Replies: 1
    Last Post: 15th March 2006, 19:11

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.