Add items to Project Explorer



  • Qt Creator 4.5.0, Ubuntu 16.04.
    The goal is to mimic an existing project, piece by piece. In that existing project, in window Projects, is the project name and its hierarchy. At the second level is a directory named libcoap. It can be opened to find several files and even subdirectories Headers and Sources.
    Create a new project. Right click and select Add New Directory. Select the same libcoap directory that I think is referenced by the original project. Qt Creator displayed the working icon for a bit then changed back to the standard arrow. It did not add a new level into the hierarchy under the project name.
    Are my basic steps correct?
    How can this structure be added in?
    Side Issue
    In the original project, right click on directory libcoap. The just opened menu does not display any properties. What can be used to discover information about these directories?


  • Qt Champions 2017

    @BKBK said in Add items to Project Explorer:

    Add New Directory

    I don't have such menu entry.

    Are my basic steps correct?
    How can this structure be added in?

    Add files to this directory (i.e. sources) that are part of the project and it will show up. If you already have the directory in place and have sources in it, use "Add existing files ..." from the project's context menu to add them to the .pro file so they can be indexed and be included in the Projects view.

    In the original project, right click on directory libcoap. The just opened menu does not display any properties. What can be used to discover information about these directories?

    What properties are you expecting?



  • @kshegunov
    Thank you for your post. I made an error. Rather than: Add New Directory I should have typed:

    Add Existing Directory

    What properties do I expect from a right click and a "Properties" selection?
    Tell me about that object. Begin with: Where it is? When <someone> added a directory or any item to the project, they added it from somewhere. Show where it was added from.

    As an example, go to Microsoft Visual Studio, start a C++ project, although any type will probably work, go to the Solution Explorer, and right click on the project, or solution, or most anything. See what Visual Studio provides for properties. Every object has properties. Please show them.

    Please try to accommodate typos as my Qt Creator workstation is not connected to my internet workstation and everything must be hand typed in. Please consider that I am a Linux and Qt novice and mention even the most obvious things I might have overlooked.



  • @BKBK
    Sorry to reply rather than edit my last post. I am working for the government computer, through some very restrictive firewalls, and my computer does not display the option needed to edit my posts.
    Thinking a bit, I decided that maybe, rather than adding an existing directory, I might create a new directory and go from there. So I right click on the project and select option Add New. There is no option to create a new directory, only add an existing one.



  • When you adding new files to the project you are free to chose where they will be created.
    After you click 'Add New...' and select template you want, click on the 'Browse' button and then (from the 'Choose Directory' dialog) create new directory where you want new file(s) to be placed. Just keep in mind that you shouldn't use spaces in the directory names.


  • Qt Champions 2017

    @BKBK said in Add items to Project Explorer:

    There is no option to create a new directory, only add an existing one.

    I think you just misunderstood how the projects are organized. What you see in the "Projects" view is not a faithful representation of the filesystem. The files that are part of the project are listed in the special .pro file, which contains the meta-information about your project - what headers it has, what soruces, forms and such and where those files are located, also external libraries to be linked and additional include directories. What you see in the "Projects" view is the result of parsing that project file and showing the contents of your project file (.pro) in a hierarchical GUI, it is not how the filesystem looks per se.

    If you want to see the filesystem layout associated with your project (again it's only for the purpose of viewing files that are listed in your project file) then you can use the "File System" view (choose from the dropdown on top. Now back to your project, you don't have an "Add new directory" menu entry, because directories are not part of the build - i.e. directories are not compiled, they don't produce binaries and such, they are only a file system detail, which is somewhat irrelevant to the build chain. You can however create a directory in your project folder, and then have source/header files in that directory, but to have them added to your project you need to use "Add existing files ..." from the context menu. On related note, you can also create new files in a specific (sub)directory by selecting "Add new ..." choosing the file type and ultimately setting its name and location (following the wizards).

    As an example, go to Microsoft Visual Studio, start a C++ project, although any type will probably work, go to the Solution Explorer, and right click on the project, or solution, or most anything. See what Visual Studio provides for properties. Every object has properties. Please show them.

    I work exclusively on Linux (with QtCreator) and the last VS that I'd used is VS2003, which was ages ago. When I test my code on windows I use QtCreator with mingw or occasionally the MS (console) compiler and debugger, which has little to do with the VS IDE. So I don't know exactly what properties you see, but I assume it's something about linkage and include headers and such. Those things you can find in creator by clicking on the Projects button in the leftmost sidebar, which will open your build/run settings for the selected active project. From there you can manage the build chain, build/run configurations, can import existing builds (very handy if you're working on a specific small part of a huge project), can change editor/code style options, dependencies and such.

    In the end 90% of the options and settings you'd modify (usually not by hand), however, reside in the project file itself. It's a simple text file for qmake (Qt's makefile generator) and you can open it by double clicking on it. Usually looks similar to this:

    # Qt modules to use
    QT += core
    QT -= gui 
    
    # Build configuration
    CONFIG += c++11 console
    CONFIG -= app_bundle
    
    #Target information (name, type)
    TARGET = targetname
    TEMPLATE = app
    
    # Possibly some defines 
    DEFINES += QT_DEPRECATED_WARNINGS # ...
    
    HEADERS += \
       # ... Headers are listed
    
    SOURCES += main.cpp \
       # ... Some other sources
    
    INCLUDEPATH += # ... External include locations
    LIBS += # ... External libraries to be linked
    

    Introduction to qmake's syntax can be found here.



  • @kshegunov
    I regret not being able to edit posts, apparently due to government computer restrictive firewalls. My computer does not display the option needed to edit my posts.
    I made an error in the original post. Rather than: Add New Directory I should have typed:
    Add Existing Directory
    That said, and that use of Add Existing Directory has not been directly addressed, still:
    The replies here are quite helpful. In particular I note the time that kshegunov spent writing the reply and explanation. Thank you.
    I think this explains much of the situation. I will need time in adapting from the Windows environment to here. With his post I will mark this as Solved.
    kshegunov: I noted your signature line and very unfortunately it is the case that two morons overrule one genius.


  • Lifetime Qt Champion

    Hi,

    You can also have a view of the content of the file system as described here in the Qt Creator manual.



  • @BKBK said...
    "As an example, go to Microsoft Visual Studio, start a C++ project, although any type will probably work, go to the Solution Explorer, and right click on the project, or solution, or most anything. See what Visual Studio provides for properties. Every object has properties. Please show them."

    If you are referring to the "solution explorer" view in Visual Studio here I am afraid you are wrong. The folders depicted in that IDE behave in the same way as the ones you see in the "Projects" view in QT Creator. If you right click on one of those "folder" icons and select the properties menu you will just get a dialog that says "There are no property pages for the selection", and if you look at the properties page for that "Folder" icon all it shows you is the name what filters are currently assigned to it and a long UID??? very useful... not.
    Anyways, they are not file system folders they are just containers only for the purpose of enabling you to organise you project files in useful manner. You are free to set that up in the same way you files are actually arranged on you disk, however I think you would find it very restricting if it forced you to strictly conform to how the folders are organised on the file system. Sometimes you may not be able to change the arrangement of a set of files and folders you are using to build your project, but you want to organise it differently in your IDE to make it conform better to your workflow or how you happen to be using them in your current project. In short what ever works for you :-)

    From your last post I sense that you are getting a feel for how IDEs work for you. Please do come back and the good folks here for help if you get stuck again.
    Good luck and happy Qt coding.


  • Qt Champions 2017

    @BKBK said in Add items to Project Explorer:

    kshegunov: I noted your signature line and very unfortunately it is the case that two morons overrule one genius.

    Mr. Szilárd just highlighted one of the greatest and very saddest realities of the democratic process. He had a rather practical approach to things, which I really appreciate. :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.