Results 1 to 4 of 4

Thread: Which is the best way to show a "full" HTML text in a Qt software?

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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.

  3. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Which is the best way to show a "full" HTML text in a Qt software?

    Quote Originally Posted by ChrisW67 View Post
    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:

    Qt Code:
    1. //HEADER
    2.  
    3. #include <QtWebKit/QWebView>
    4.  
    5. private:
    6. QWebView view;
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. ///CPP
    2.  
    3. view = new QWebView;
    4.  
    5. ///ERRORS:
    6.  
    7. D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:11: error: undefined reference to `_imp___ZN8QWebViewC1EP7QWidget'
    8. D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:11: error: undefined reference to `_imp___ZN8QWebViewC1EP7QWidget'
    9. :-1: error: collect2: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. ///CPP
    2. view = new QWebView(this);
    3.  
    4. /* or
    5. view = new QWebView(ui->Tab);
    6.  
    7. or
    8.  
    9. view = new QWebView(ui->Tab->widget(1)); //To indicate that I want to create the QWebView in the second tab of the QTabWidget
    10. */
    11.  
    12. //ERRORS:
    13.  
    14. D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:11: error: undefined reference to `_imp___ZN8QWebViewC1EP7QWidget'
    15. D:\- Meus Documentos\Minhas obras\Softwares\mAcy\mAcy 0.03\body.cpp:11: error: undefined reference to `_imp___ZN8QWebViewC1EP7QWidget'
    16. :-1: error: collect2: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 


    So I imagine that I'm gonna have problems if I add a web browser component!!


    Thanks,

    Momergil.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 3
    Last Post: 8th December 2011, 19:21
  2. Replies: 4
    Last Post: 5th March 2010, 18:03
  3. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  4. QWidget pixmap AFTER displaying html ("rich text")
    By gavrilo princep in forum Newbie
    Replies: 0
    Last Post: 17th July 2007, 01:59
  5. Creating a "windowless" software
    By Yorma in forum Qt Programming
    Replies: 7
    Last Post: 9th January 2006, 15:21

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.