how to write and read a text to and from a LineEdit using QT Creator? - c++

I am working with QT Creator. I have a form that contains a push button and an Line Edit. I would like to print a string that i give programatically in this LineEdit.Secondly I would also like to the from the LineBox a string that I fill in and print it using QMessageBox.
How to do it? Need some help. I don't know how to access the displayText() to write and read from a LineEdit.
I would like to specify that I put the push button and the lineedit on the Form using drag and drop.
I am working in c++ under Ubuntu
Appreciate.

You use QLineEdit::setText() to change the text and QLineEdit::text() to read.
Your questions are very basic and show a clear lack of studying the documentation and experimenting thing yourself. Qt is one of the better documented frameworks out there and with lots of examples. Please take your time to go through them.

Related

Qt: How to Write a Windows Desktop Utility?

I've used Qt for widget development a fair bit. That's straightforward. But how could I write a program that can be invoked from anywhere on Windows?
Say I've selected some text in a web browser. I want to be able to invoke my program via keystroke, maybe show a little list containing a list of text files I can select (ideally where the cursor is), and then add the selected text to that file.
How can I do this?
I suggest you to have a look at:
https://skycoder42.github.io/QtService/index.html
https://forum.qt.io/topic/67043/qt-daemon

How to use Qt to build a command window?

I totally have no idea. Any suggestion on it? It is a command window accepting some commands like:
> Add(1, 2)
and other similars.
This is a very vague question. Since there is no built-in parser generation in Qt, you can combine boost or YACC to get parsing. Use a QInputDialog or a QTextEdit from Qt for input and display. Basically set up some events in Qt for the parsing.
Have a class extending QInputDialog storing a string cmd. This class has a parsing function which will call the right code from the entered command or report an error. Then store a set of completed commands or outputs which you display back to the user. For exact code, you need to try something, and look at some tutorials, and ask more SO questions :)
Hope this is an ok start to get your mind going.

How to get text to display in a TextBrowser in Qt?

I am new to c++ and even newer to Qt on Linux.
Can any one give me a general idea of how to display text in a textbrowser in Qt? I can't post my code because of the seative nature of the project I am working on. All I need is a basic understanding of how to do this related to slots and signals.
My application is this: I am taking input from a CSV file, counting the ords and then displaying the number of counted words along with the line of text in an output window.
It works fine in console c++ program. However, when I code it in Qt, it does not work.
Any advise or help would be welcome.
sorry for the bad question I asked earlier.
It turns out it was a configuration issue on my part.

A simple phonebook using FLTK in c++

Hi guys I want to make a phone book in c++ using FLTK as a part of my project. It should have options to add, delete,modify and search the numbers.
Since I am new to FLTK can some one suggest which widgets should I use and how?
Also I am planning to write the contents of phonebook into a text file whose entries will be retrieved/ written into as and when required. So non graphical code is easy . Can some suggest how do I integrate graphics into this using FLTK?
Thanks in advance
I'd suggest you first draw a sketch of the user interface in a paper. Like this for instance :
Then you go here : http://www.fltk.org/doc-2.0/html/index.html and find the names of the widgets you need. Optionally, do the Hello World example so that you understand how FLTK is compiled into a C++ program. Some hints : you want a button for Add, Modify and Delete, an input for the Find and for editing the details of each entry plus a select browser for the list of names.

How to extract selected area of the gui component to PDF in QT

I need to make the tool like Snagit and to take the picture the selected area of the component. I'm searching how to make this tool in Qt.
I firstly prefer using Qt native library but if there is no library which fullfills this requirement, any good c++ libray can be accepted for me.
Any help will be appreciated.
Thanks
I'm not sure to understand exactly what you want. I assume you want to take a screen shot ? and then put this picture into a PDF document.
To take a screenshot with Qt, have a look at this :
http://doc.qt.nokia.com/4.0/widgets-screenshot.html
This will show you how to take a screenshot (using QDesktopWidget) and get a QPixmap.
You can then display this QPixmap into a QTextDocument (see QTextDocument::addResource) and print this document into a PDF file. Something like this :
QPrinter MyPrinter(QPrinter::HighResolution);
MyPrinter.setOutputFormat(QPrinter::PdfFormat);
MyPrinter.setOutputFileName("test.pdf");
MyPrinter.setPageSize(QPrinter::Letter);
MyPrinter.setColorMode(QPrinter::GrayScale);
MyPrinter.setOrientation(QPrinter::Landscape);
MyTextDocument.print(&MyPrinter);