Which is the best way to show a "full" HTML text in a Qt software?
Hello!
I'm planning to use a widget in one of my softwares that is going to show a "full" html text, that is, a html text that not only contain text, but images and so forth. For the time being, the text is going to be place in a .txt file and the software, in a given time, is going to read the html code and show in that widget.
But which is the best widget to be used in this case? QLabel? QTextEdit? QPlainTextEdit? Or even other?
For the time being, I'm using QLabel inside a QScrollArea, but I'm not sure if that is the best option.
Thanks for any tip.
Momergil
Re: Which is the best way to show a "full" HTML text in a Qt software?
You want a web browser component... I'm sure you can find that in Qt Assistant.
Re: Which is the best way to show a "full" HTML text in a Qt software?
Quote:
Originally Posted by
ChrisW67
You want a web browser component... I'm sure you can find that in Qt Assistant.
Hello, Chris!
Thanks again for the reply.
Well, I'm gonna give a look than in the Qt Assistant ( you mean this one, yes? [http://doc.qt.nokia.com/4.6/assistant-manual.html]).
The problem, though, is that if this means to use the QWebView class, than I imagine I'm gonna find problems to use it in my software. For another reason I want to use the QWebView in my software - to display Wikipedia's articles when the user clicks in the "Wikipedia" tab in a given place - and despite the "fancy browser" exemple runs OK when I compile and execute it in the Qt, I simply am unable to include it in my software. If I simply include it by the Ui interface, the compiler shows:
:-1: error: collect2: ld returned 1 exit status
and it doesn't run. I added no code till then, but that is what it shows. But if I try to include it from the h/cpp files:
Code:
//HEADER
#include <QtWebKit/QWebView>
private:
QWebView view;
than the compiler shows:
D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:6: error: undefined reference to `_imp___ZN8QWebViewC1EP7QWidget'
D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:21: error: undefined reference to `_imp___ZN8QWebViewD1Ev'
D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:6: error: undefined reference to `_imp___ZN8QWebViewC1EP7QWidget'
D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:21: error: undefined reference to `_imp___ZN8QWebViewD1Ev'
D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:26: error: undefined reference to `_imp___ZN8QWebViewD1Ev'
D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:26: error: undefined reference to `_imp___ZN8QWebViewD1Ev'
D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:26: error: undefined reference to `_imp___ZN8QWebViewD1Ev'
:-1: error: collect2: ld returned 1 exit status
And if I include it as a pointer, everything runs ok, but when I point the pointer to a QWebView, new problems arise:
Code:
///CPP
view = new QWebView;
///ERRORS:
D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:11: error: undefined reference to `_imp___ZN8QWebViewC1EP7QWidget'
D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:11: error: undefined reference to `_imp___ZN8QWebViewC1EP7QWidget'
:-1: error: collect2: ld returned 1 exit status
Code:
///CPP
view = new QWebView(this);
/* or
view = new QWebView(ui->Tab);
or
view = new QWebView(ui->Tab->widget(1)); //To indicate that I want to create the QWebView in the second tab of the QTabWidget
*/
//ERRORS:
D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:11: error: undefined reference to `_imp___ZN8QWebViewC1EP7QWidget'
D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:11: error: undefined reference to `_imp___ZN8QWebViewC1EP7QWidget'
:-1: error: collect2: ld returned 1 exit status
So I imagine that I'm gonna have problems if I add a web browser component!!
Thanks,
Momergil.
Re: Which is the best way to show a "full" HTML text in a Qt software?
It pays off to read the docs. Try answering a question "how do I enable using 'QtWebKit' module in my app" - hint: Open Qt Assistant (not the webpage but the program you have on your computer), find the docs for QWebView, scroll up and in the breadcrumbs click on the link directly to the left of the "QWebView" label. Then start reading and read all the way down, even if you think you already know how to solve your problem.