KDevelop4/TipsAndTricks/fr: Difference between revisions
(Created page with "De nouveau, un gain de temps très pratique!") |
ChristianW (talk | contribs) (Created page with "Ceci fonctionne même pour les fonctions :") |
||
Line 68: | Line 68: | ||
# declare private <code>int myVar</code>, same as above, but in private section. | # declare private <code>int myVar</code>, same as above, but in private section. | ||
Ceci fonctionne même pour les fonctions : | |||
{{Input|<syntaxhighlight lang="cpp"> | {{Input|<syntaxhighlight lang="cpp"> | ||
class foo { | class foo { |
Revision as of 13:37, 29 July 2018
Trucs Et Astuces
Complétion de Code
Alors que vous avez la complétion automatique de code, en faire la demande manuellement est souvent une très bonne idée. Appuyez sur Ctrl + Space et vous obtiendrez une liste détaillée de complétion de code. Naviguez avec les flèches (Haut/Bas) et appuyez (et laissez appuyer) Alt pour montrer la documentation de l'élement ciblé. Appuyez sur Entrer pour insérer l'élement.
C++ Type Assistant
Supposons que vous ayez quelque chose de semblable à ceci:
#include <vector> void myFunc(const std::vector<int>& v) { }
Maintenant, vous voulez parcourir le contenu, au lieu d'écrire le type de l'itérateur, écrivez simplement:
it = vector.begin();
Maintenant, attendez une seconde jusqu'à ce que l'assistant apparaîsse au bas de l'éditeur. Appuyez sur Alt + 1 pour exécuter l'assistant et vous vous retrouvez avec:
std::vector< int >::iterator it = v.begin();
Bien, beaucoup de temps de gagné. Et cela devrait fonctionner avec la plupart/toutes des expressions, dès que le côté droit peut être évalué, vous devriez obtenir un assistant qui ajoute le type correct sur le côté gauche.
C++ Signature Assistant
Exemple de code:
class foo { int bar(); }; int foo::bar() { }
Maintenant essayez les choses suivantes et après chaque étape attendez un peu et appliquez l'assistant qui apparaît en bas de l"éditeur avec Alt + 1:
- ajoutez un paramètre, ex:
int foo
soit à la signature de la définition ou de la déclaration. - faites une signature
const
- changez le type de paramètre
- retirez le paramètre
De nouveau, un gain de temps très pratique!
C++ Missing Declaration Assistant
Example Code:
class foo { int bar(); }; foo::bar() { }
Now write this into the implementation of bar:
myVar = 1;
You should get an assistant that offers you three options:
- declare local
int myVar
(see type assistant above) - declare public
int myVar
, adds the declaration to the class body - declare private
int myVar
, same as above, but in private section.
Ceci fonctionne même pour les fonctions :
class foo { }; int main() { foo f; }
Now write this below foo f;
:
f.someFunction(1, true, "asdf");
The assistant now offers you to declare that function, you'll end up with:
class foo { public: void someFunction( int arg1, bool arg2, const char* arg3 ); };
Overload Helper
Example code:
class A { public: virtual A* foo(int something){} }; class B : public A { };
Inside the class body of B
press Ctrl + Space to bring up code completion. You should notice an item to overload foo(int something);
. Execute it with Enter and you should get:
class B : public A { public: virtual A* foo(int something); };
Implementation Helper
Continue where we left of in the Overload Helper:
class B : public A { public: virtual A* foo(int something); };
Place your cursor below the class context, request code completion with Ctrl + Space, you should notice an item to implement B::foo(int something);
. Execute it with Enter and you should get:
A* B::foo(int something) { A::foo(something); }
Quick Open
is probably one of the features in KDevelop that increases productivity:
- Quick Open Files
Press Ctrl + Alt + O and type part of a filepath, press Enter and the selected file gets opened. The search is separated by forward slashes, i.e. you can write this: /a/.cpp
and the list will only show paths that have a folder starting with a
and files that end on .cpp
. Try it out.
- Quick Open Classes
Ctrl + Alt + C and input (parts) of the qualified class identifier, press Return and jump to the declaration of that class.
Also make sure to explore the other advanced features in
.Outline
Similar to quick open, pressing Ctrl + Alt + N gives you an outline of the current document with the ability to search for an identifier and quickly jump to its declaration.
Context Browsing
Hover a use, declaration or definition and you'll get a popup with information about it. You can also move your cursor in there and press (and keep pressed) the Alt button to show that popup without using the mouse. Use the arrow keys to navigate between the links in the popup, use Enter to jump to the destination of a link.
When inside a use, press Meta + Left or Meta + Right to jump to the previous/next use. Press Ctrl + . or Ctrl + , to jump to the declaration or definition of the symbol under the cursor. Alternatively click on a symbol with Ctrl button pressed to do the same.
Also take a look at the
menu and it's various shortcuts. Context browsing is awesome!How to work with autotools: automake, autoconf and libtool
KDevelop 4 does not support very well the autotools. I suggest using Konsole to run configure scripts to build makefile. The custom makefile support works quite well. I suggest using separate building folder (say project/build).
After the custom makefiles are in place (say in build-directory) one can add that to build list by clicking the button on lower left corner Project selection while build directory is selected. This causes command make to be run when pressing . One can also directly run say make install on specific directory by right clicking the folder and selecting make install. This is nice if you have lots of projects in working set.
Libtool also causes problems if you try to debug application that has been linked with libtool: the program that you see in for example src/bin/program is not the executable, but a script that handles the libraries.
Problem is properly solved in console by running
libtool --mode=execute <dst_binary>
but at least currently KDevelop4 does not work good (at all) with other console than default. I have been stuck of using the real binary (found usually from src/bin/.libs/<exec>) that might use wrong libraries, so do make install before every run.
KDE Classes Documentation
Using the Qt Documentation plugin you may integrate KDE documentation along with Qt documentation. Point your browser at KDE API Reference and download the desired .qch file (not all modules provide one). Then configure the Qt Documentation plugin by adding the downloaded files. That's it! Whenever you hover a KDE class you can see a link which points to KFooClass documentation. Enjoy.