Results 1 to 3 of 3

Thread: main.cpp in creating new QWidget project

  1. #1
    Join Date
    Sep 2012
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Lightbulb main.cpp in creating new QWidget project

    Hi Guys!

    I'm a little bit confused about this one. Can someone explain to me what is the main purpose of the automatically generated main.cpp when creating new QWidget project? Can I delete the main.cpp file? Or i need some modifications first before deleting the main.cpp?

    Thanks in advance guys! I'm new in Qt!

    This is the structure:

    -Trial.cpp
    -Main.cpp

    -Trial.h

    -Trial.ui

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

    Default Re: main.cpp in creating new QWidget project

    The main purpose of the code in main.cpp, which is just a main() function, is exactly the same as the main() function in any C++ program: its the starting point for running your program.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,072
    Thanks
    233
    Thanked 649 Times in 639 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: main.cpp in creating new QWidget project

    Can I delete the main.cpp file?
    You can delete the main.cpp file but, as ChrisW67 said, you can't delete the main() function. That's the entry point to your program. You can move that function to another file (like Trial.cpp), but it has to be somewhere and it has to have the name main() with the correct arguments and return value.

Similar Threads

  1. Replies: 2
    Last Post: 29th June 2011, 14:24
  2. Change Main Entry Point in Qt Project File
    By Sanuden in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2010, 18:44
  3. help creating a project file
    By Slewman in forum Qt Programming
    Replies: 10
    Last Post: 23rd December 2009, 11:42
  4. Creating a Main Window Application
    By gt.beta2 in forum Qt Tools
    Replies: 13
    Last Post: 24th February 2009, 19:45
  5. Creating project in designer
    By safknw in forum Qt Tools
    Replies: 3
    Last Post: 10th May 2006, 14:11

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.