whats differences between setInformativeText &setText functionaly? - c++

In the QMessageBox class in QT there are setText & setInformativeText functions,whats function of second one while it do any thing that first do?

Qt documentation says about informativeText:
On the Mac, this text appears in small system font below the text().
On other platforms, it is simply appended to the existing text.
So if you don't use your application on Mac then you can just use setText with whole text you want to display to user.

Related

How to add the OS X flavor to a Qt app

I have used Qt previously only in the form of PyQt, and today I tried the original version of Qt in C++.
I got it working, however, when if start up my app, I have several problems with it:
it's stationary, which means, I cannot drag it across the screen
I cannot change the size of the window
it does not have a OS X type status bar (which contains the three colored buttons and the name of the window)
How can I add these features to my C++ Qt app?
I have tried to look for a solution, but only found QtApplication::setStyle();, which did not solve my problem.
You can see the code here.
The code inside your subclass of QMainWindow contains this line:
setWindowFlags(Qt::FramelessWindowHint);
That is probably causing most of the problems you describe. Try removing that line.

QT Creator and documentation popup [duplicate]

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.

display printf output in main window in QT

I am new to Qt programming, I have made a simple gui with a single push button. Basically I have written a program in C++ now I want to make Gui for my project. I want to display output of all printf statement in my gui. printf statements showing their output in console but I want to add something similar to console in my gui so that whenever I call printf statement it shows its result in the gui. Could you please guide me how can I do this?
You can use a QLabel to show your output in the GUI.
Everytime you call printf, you call setText(...) instead. Now the debug text will be shown in the text label in your GUI.
You can add several QLabels for different debug outputs, if you want.
EDIT:
This could also be of interest.
use QProcess start your CLI program and use readData/writeData to get your information and put them into a QTextEdit
I have found the answer of my question, I have used textbrowser in gui and make a function which I call for printing my data in gui. I can not show the picture of my gui because I have less reputations.
here is the function that I have used for printing.
void MainWindow::print(const QString &input){
data_lab += input;//to display all data in stream
ui->label->setText(input);
ui->textBrowser->setText(data_lab);
}
and here is the call of function from main.
w.print("hellok\n");
w.print("l\n");
I hope this will help somebody like me.

how to set a text in line edit Qt Creator?

I am working in c++ Qt Creator. I have a form with labels and lineEdits. I would like to set as default in each lineEdit a text. It would be more efficient than writing the same stuff each time I run the application. Can you please tell me how to do this?
Qt has a concept of properties, and for each property, there's usually a getter and a setter, in your case "Text" (as also displayed in the designer) -> void setText(QString), QString text().
As a serious advice: Learn to use the excellent documentation. Nearly everything in QtCreator lets you open a context-sensitive help via F1. And read some introductions;
Use
void setText( const QString & )
You can set it in the constructor or maybe set all those defaults in an init() function.
Read thorugh the documentation.
Why not just set it to your default value at start? Would be the easiest way if you know how to set a textedit to a value anyhow.
hope this helps, tell me if you need aything more
When you double click in the UI designer on the QTextEdit you can enter a default text which is set every time your application is run.
Alternate you can set the text using setText(QString) function in the constructor of your window.

MFC CEdit placeholder text

How do I have a CEdit control display placeholder text when it's empty, similar to the behavior of NSTextFields in Cocoa?
Ages ago, I wrote a custom paint routine to do it, seemed to work fine.
Sometime after, they introduced SetCueBanner to CEdit, but I can remember it:
a) not working correctly
or -
b) not behaving the way I wanted
Perhaps it will work fine for you. If not, I can see if I can find my old code and post what I did in the custom paint routine.
EDIT
I just checked the Win32 docs, I think this is why I abandoned it:
You cannot set a cue banner on a multiline edit control
you could create a small window over the top of it that contains the placeholder text. Then when the user sets the keyboard focus to it hide the window and if the focus is removed and nothing is in the box then show it.
The SetCueBanner banner function is now working.