QML/qdoc : How to define inheritance and import statement

236 Views Asked by At

I made a qml library and I now want to make a documentation. I use QDoc with Qt 5.10.10 with msvc2015 and LLVM 9.0.0.

I would like to display the 2 following data:

enter image description here

  • inheritance: I tried to use \inherits but I don't see any result. I tried to use an Item from QtQuick (with QtQuick::Item) and an item from my own library. Am I missing something ?
  • Import statement: I just don't know what to do. It seems I have to use \qmlmodule but I have an error whether I use it on my qdocconf or in my qml file.

Below the code I currently have:

// MyButton.qml - the header
    /*!
    QtQuick.Controls 1.1

    \qmltype SolidButton
    \qmlmodule MyModule
    \inherits QtQuick::Button
    \brief My button. It inherits from Button from QtQuick.

    \section1 Detailed Example

    \qml
    MyButton {
        text: "My Button";
    }
    \endqml
    */

// qdocconf

    sourcedirs += ../qml/
    headerdirs += ../qml/
    imagedirs = .

    sources.fileextensions = "*.qml"

    outputdir  =    ./doc/qml/
    outputformats = HTML

    HTML.stylesheets = style.css
    HTML.headerstyles = "<link rel=\"stylesheet\" type=\"text/css\" href=\"style/style.css\"/>\n"

----- EDIT: As asked in the comment, here the error I have

  • Inheritance: I just don't see any result. \inherits has no impact with a qt control or my own local controls
  • Import statement. If I try to use the \qmlmodule on my qml file I get this error enter image description here If I do nothing, I get this: enter image description here

----- EDIT 2: I should also mention that I am using Visual Studio, not Qt Creator

1

There are 1 best solutions below

1
On

\qmlmodule is not allowed in a qml file. You have to add it to a separate myQMLmoduleName.qdoc file:

 /*!
  \qmlmodule MyControls
  \brief Mycustom controls.
*/

then add the *.qdoc extentions to your myConfig.qdocconf for qdoc to find your myQMLmoduleName.qdoc.

# what kind of sources should be processed
sources.fileextensions += "*.qdoc *.cpp *.qml"
sourcedirs += ../path/to/your/config/