QT Creator and documentation popup [duplicate] - c++

When you place the mouse pointer over any Qt function/class it shows a pop-up with short description of what it does, taken from the docs in the comment above the function/class.
For my functions/classes I have documentation in the doxygen format:
/**
Returns foo
*/
QString getFoo() {
return "foo";
}
When this function is used, I want to view the same type of pop-up with my docs when the mouse pointer is over the function name.
Is it possible to do that with Qt Creator?

Unfortunately it's not possible for Qt Creator (as of the recently release 2.4) to pick up the tags on-the-fly. However, what might work is to let doxygen run, and tell it to create qch files. If you register the created qch file, you should get mouse-over and even a proper help file. See http://www.ogre3d.org/tikiwiki/Integrating+API+documentation+into+Qt+Creator+Help for how Ogre3D does it. YMMV if that's worth it for a fast-changing project. It's certainly a good idea for a (semi-)stable library.
Relevant bug report: https://bugreports.qt.io/browse/QTCREATORBUG-4557

Qt Creator requires the generated docs to have some special markers in order to retrieve the tooltip text. I couldn't find a way to insert these markers with Doxygen so I've created a simple script to do it:
https://github.com/mmmarcos/doxygen2qtcreator
It's not bulletproof but it allows us to integrate our classes and methods briefs into Qt Creator tooltips.

Related

How to create an Evernote kind of widget for global menu of a MacOS/X desktop using QT?

How to create an application which stays in top of MacOS, something similar to below image. You can see the Evernote elephant icon.
I don't want to use xcode - because my application already built in QT, it has nice GUI, now I wanted to add extended feature something similar to Evernote. If I click on an elephant it will open a dialog box to write notes. In my case- it's a simple event like on/off buttons.
I have tried and created GUI widget apps but how to make one which resides like Evernote app ?
A custom pop up menu like the one pictured can be done several ways in Qt.
QML is the most modern way of making the menu with the customized styling you are looking for.
Apply the appropriate flags to the window/widget so it appears as a popup.
The same effects can also be done in QWidgets, but takes more code and probably will take longer to make. The flags you are looking for will be found under Qt Window Flags and/or under Qt Widget Attributes.
The stock stylings for Qt for different OS's deal mostly with title bars, status bars, buttons, drop downs, etc.
The base styles for Mac can be found here:
http://doc.qt.io/qt-5/gallery-macintosh.html
Once you go to a customized popup, you have to draw all of it yourself... but the native drawing elements in Qt are friendly enough and get you that look you are trying to do.
There are even some tools for exporting from Photoshop or Gimp directly to QML.
http://doc.qt.io/qtcreator/quick-export-to-qml.html
Hope that helps.
You are looking for a tray icon. Qt implements it in QSystemTrayIcon.
Further information
You may take a look at the System Tray Icon Example.
Many StackOverflow posts exist on this topic.
If you already have a program written for Qt, then you can compile and run it under MacOS/X much the same way you could compile it under (whatever OS you're using now). You'll need to install Xcode because Xcode includes the C++ compiler (clang) you'll need in order to compile your Qt program, but you don't have to use the Xcode IDE if you don't want to. Rather, you can either use the QtCreator IDE under MacOS/X, or you can simply open up a Terminal window and do a "qmake ; make" in the directory where your Qt-based program's .pro file is, and build it from the command line that way.
If, on the other hand, your question is actually about how to add an icon to the global menu of a MacOS/X desktop, then I don't think Qt has an API for that, so you'll need to drop down to using one of MacOS/X's native APIs. That will probably involve learning some Objective-C (or Objective-C++, if you prefer), but integrating a bit of Objective-C/C++ into your Qt app is doable with a bit of work.

Is the Qt source code complete?

I want to create some custom widgets for my Qt application and thus I need to reimplement some slots.
Now I searched the Qt source code and found i.e. the cpp file of QSlider (see here). I looked for the implementation of setValue(int), and it is mentioned in the comments a few times, but I couldn't find the implementation.
This led me to the conclusion that either the source code is not complete or that I'm missing something.
The method setValue is inherited from QAbstractSlider, you can see its source here.

Qt Creator 2.8.1 Qt 5.1.1 Qt Designer Linux Show a new Form

I am a beginner with Qt - so hopefully this will be an easy question to answer. I have a reasonable amount of experience with C++, that part is not a problem
The purpose of my application is to do code generation, initially to make header & implementation files for classes. I quite like the Class wizard on Code::Blocks, but I reckon I can do a lot more.
I have a main Widget which has a tabWidget & some lineEdit's & some pushButtons. To preview what will eventually be in the file, I have created a new Form, with a TextBrowser in it. The new Form entry appears in the .pro file.
I would like to have the new Form displayed when I press the pushButton, & I am intending to write text in the TextBrowser based on the contents of the lineEdit's in the main Widget.
I have been looking through the documentation all afternoon, but most of the examples show either a main widget or a Form by itself. I have seen the example of the Class Wizard (which is nearly what I want to do), but I would rather a tabWidget interface. Being able to open a Form from a button is a pretty basic thing to be able to do.
For some reason, the examples page in my QtCreator help doesn't show any examples - previous versions had heaps of examples. Not sure why that is.
Do I have my terminology mixed up - should I have a Dialog rather than a Form? Not sure what the difference is.
Apologies in advance if all this is in the documentation somewhere, I seem to spend hours trolling through it, so maybe someone could provide some links - that would be great.
Suppose the new form you created along with with header and cpp file is mynewform.h, mynewform.cpp and mynewform.ui
Now include mynewform.h in your mainwindow class,
and create an object of the class
mynewform myform;
In the clicked slot of pushbutton just type:
myform.show();
or
myform.exec(); //(if you want a blocking call)

How do you programatically update the UI in Qt?

I'm fairly new to Qt, and am trying to wrap my head around signals and slots. Though I've figured out how to create custom slots, I've yet to figure out how do update the GUI from my C++ code. I realized that the entire UI, which I created in the designer, is only written in what appears to be XML based UI code. Do I have to handwrite my own Qt C++ UI in order to update the interface, or can I somehow use C++ to update the XML based UI? I'm just looking to add a widget to the main form on a button click. Any help is appreciated. Thanks!
To add a widget to a form you can simply do
ui->layout()->addWidget(new Widget);
XML is used by QtDesigner as a mean to create, update, and persist your GUI, enabling a visual approach to development, but in the end you can build your application entirely without it.
you dont havfe to update the xml of UI . you can inherit the ui into your own class using setupUi
http://crpppc19.epfl.ch/doc/qt4-doc-html/html/qwidget.html#setupUi
now in your C++ class you can update the widgets like changing label text, lineEdit text, setting up spinbox value using Signals & slot.
That xml is used by Qt designer and outside of designer it's only used by uic as a source to generate C++ code, so everything that you do in the designer end-up as C++ code, so it can be updated (or done completely) in C++ code (you can look into the code and see that you most likely have a member called ui that is most likely a pointer, but it can also be an instance of a C++ class that is generated for you by uic, and trough that ui member you can access the widgets and layouts that you created in the designer).
A generic resource that i recommend you to read can be found here and then (if you still can't figure it out) ask a specific question about what exactly are you trying to achieve.
LE: that link contains 3 methods to use the generated code into C++ code, don't try all of them into your working project, you may choose one method or use the default one (ui member pointer)

Implementing drag and drop with QT 4.5 using QT Creator environment

We're about to commit to Qt and C++ (sigh) to do some cross-platform development. The latest version of Qt 4.5 seems very nice as does the QT Creator IDE, which although simple compared to other IDEs, is a good way to get started.
I'm trying to understand how to do drag and drop into QT widgets from the "outside" world. As far as I can tell from the documentation, you're supposed to subclass a widget that you want to have respond to drop events and override some methods (the dragEnterEvent and dropEvent member functions) for that widget.
But if I use the Qt Creator tool, I don't seem to have any access to the classes of the widgets that I have created using the GUI form builder and so I can't subclass them.
WHat's the secret?
Thanks in advance,
D
Someone on my team figured it out ---- turns out there is an option to "Promote" a widget, meaning you can subclass it to something else and then override the needed methods with no pain.
Seems to me it would have been more obvious if it said "Subclass widget..." rather than "Promote" but that's OK.
This QT Creator is a very nice piece of work.
I've never used QT creator environment, but I assume it spits out code afterward. Can you edit the code it spits out?
If you subclass the classes in a separate file, it shouldn't get overwritten when you rebuild your app with QT creator environment.
I suppose this is really a question for the QT creator forum though, sounds like a problem in THEIR user interface.