Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Simple question : What is //! [0] ...etc in the editor?

Simple question : What is //! [0] ...etc in the editor?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 831 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    codewriter
    wrote on last edited by
    #1

    When i look at the mainwindows.cpp file of the dockwidgets example, I see the following which has //! [0] and so forth......what are these and what do they do?:

    //! [0] <<<<<<------------------------------------------------------------WHAT IS THIS?
    #include <QtWidgets>
    #ifndef QT_NO_PRINTDIALOG
    #include <QtPrintSupport>
    #endif

    #include "mainwindow.h"
    //! [0] <<<<<<--------------------------------------------------------------WHAT IS THIS?

    //! [1] <<<<<<--------------------------------------------------------------WHAT IS THIS?
    MainWindow::MainWindow()
    {
    textEdit = new QTextEdit;
    setCentralWidget(textEdit);

    createActions();
    createMenus();
    createToolBars();
    createStatusBar();
    createDockWindows();
    
    setWindowTitle(tr("Dock Widgets"));
    
    newLetter();
    setUnifiedTitleAndToolBarOnMac(true);
    

    }
    //! [1]

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      First of all, they're comments. They start with "//", so all C++ compilers ignore those lines.

      Secondly, they're documentation comments. Special tools like "Doxygen":http://www.stack.nl/~dimitri/doxygen/manual/docblocks.html#cppblock and Qt's internal "QDoc":http://qt-project.org/doc/qt-5.1/qdoc/01-qdoc-manual.html will interpret "//!" as documentation markers.

      In this example, you're looking at "code snippets":http://qt-project.org/doc/qt-5.1/qdoc/07-0-qdoc-commands-includingexternalcode.html#snippet: When QDoc sees those markers, it will copy the marked code into other documentation articles. "//! [0]" marks the start/end of a snippet labelled "0"; "//! [1]" marks the start/end of a snippet labelled "1", and so on.

      You can see the result of your example at "here":http://qt-project.org/doc/qt-5.1/qtwidgets/mainwindows-dockwidgets.html

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved