Results 1 to 7 of 7

Thread: Qt GUI print global variables

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Qt GUI print global variables

    Quote Originally Posted by d_stranz View Post
    @jefftee: This has nothing to do with the event loop or event processing. cout is plain old C++. And unfortunately, Arduino and RasPi coding books have brought back the evil global variable with a vengeance. From the names of the variables, this seems to be what this is about.
    Thanks, I jumped to the wrong conclusion... I still feel that global variables are an indication that you have poorly designed your classes/interfaces and a crutch used by too many people just to make it work...

    Edit: after reviewing the code, he's creating the same variable names in two different namespaces (global and global2) so they are indeed different variables and I don't see where they are ever initialized either.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  2. The following user says thank you to jefftee for this useful post:

    d_stranz (27th April 2017)

  3. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,330
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt GUI print global variables

    he's creating the same variable names in two different namespaces (global and global2)
    Ah, and I missed that detail. Even if he does initialize the variables in the "global" namespace, the variables in "global2" remain uninitialized.

    And I agree about global variables also. The closest I ever come are static const variables in cpp module scope or singleton classes that can only have one instance. But as I said, pick up any Arduino or Raspberry Pi coding book and they are in every example. It might be the most straightforward way to teach coding for single board computers, but it teaches bad habits that don't scale well when used in real-world applications.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 1
    Last Post: 2nd September 2013, 22:52
  2. Are global variables evil?
    By Wonk0 in forum Newbie
    Replies: 3
    Last Post: 2nd February 2011, 20:11
  3. Qt and global variables
    By Morea in forum Qt Programming
    Replies: 11
    Last Post: 1st February 2007, 23:42
  4. Global variables
    By Mariane in forum Newbie
    Replies: 14
    Last Post: 10th October 2006, 17:23
  5. declaration of global variables???
    By pranav_kavi in forum Newbie
    Replies: 6
    Last Post: 31st January 2006, 19:56

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