Results 1 to 6 of 6

Thread: QT QTextBrowser problem with setText

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default QT QTextBrowser problem with setText

    HI,
    i have a problem with my qt program.
    first of all i have a QTextBrowser and a Button. when the button is clicked it should call a method from a c++ class like this:

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6.  
    7. }
    8.  
    9. MainWindow::~MainWindow()
    10. {
    11. delete ui;
    12. }
    13.  
    14. void MainWindow::on_Button_clicked()
    15. {
    16. try{
    17. GUIController guiController;
    18. guiController.somemethode();
    19.  
    20. }
    21. catch (char const* err){
    22. cout << err << endl;
    23.  
    24. }
    25.  
    26. }
    To copy to clipboard, switch view to plain text mode 

    This called methode should do something and then call a method from mainwindow class which should set Text to the textBrowser like this:

    Qt Code:
    1. GUIController::GUIController()
    2. {
    3.  
    4. }
    5.  
    6. GUIController::~GUIController()
    7. {
    8.  
    9. }
    10.  
    11. void GUIController::somemethode{
    12. ...
    13. ...
    14. mainwindow.printToOutput(("text"));
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6.  
    7. }
    8.  
    9. MainWindow::~MainWindow()
    10. {
    11. delete ui;
    12. }
    13.  
    14. void MainWindow::printToOutput(QString text){
    15.  
    16. ui->outputText->append(text);
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 

    But the problem is that the text doesn't appear in the QTextBrowser.
    Has anybody an idea whats the problem?
    i googled a long time and i think the problem is something with the "render loop" of the gui but i don't know how to fix it.

    Thanks for help!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QT QTextBrowser problem with setText

    Your GUIController instance does not have any access to the MainWindow instance.
    How do you expect the controller to affect an object it doesn't know about?

    Cheers,
    _

Similar Threads

  1. QPushButton setText problem
    By batileon in forum Qt Programming
    Replies: 3
    Last Post: 3rd December 2008, 03:02
  2. QLabel setText Problem
    By pmabie in forum Qt Programming
    Replies: 10
    Last Post: 1st November 2007, 23:32
  3. Problem with QLabel and setText
    By jambrek in forum Qt Programming
    Replies: 7
    Last Post: 31st October 2007, 16:02
  4. Problem with QLineEdit and setText
    By Elmo23x in forum Qt Programming
    Replies: 8
    Last Post: 12th April 2007, 12:35
  5. Qtable--setText problem
    By :db:sStrong in forum Qt Programming
    Replies: 1
    Last Post: 21st July 2006, 10:25

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.