Results 1 to 1 of 1

Thread: QTextEdit and Painter problems

  1. #1
    Join Date
    Feb 2008
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default QTextEdit and Painter problems

    I have a series of widgets that I use to draw a series of graphs on them. I also have it set up to show and hide the graph widgets. When the widgets are shown or hidden all the graph widgets resize to fit the new widget.

    However I wanted to add a QTextEdit widget so that I might be able to display some information. However, when I add the QTextEdit widget to the main qui, when I try to hide a widget and then resize the others all of the widgets disappear.

    Can anyone help me understand what is going on or give me some suggestions as to why this is happening.

    Here is some code if you need to see how I have things set up.

    Qt Code:
    1. bla::bla(QWidget *parent) : QWidget(parent)
    2. {
    3. mainlayout = new QVBoxLayout(this);
    4. bottomlayout = new QHBoxLayout;
    5. buttonlayout = new QVBoxLayout;
    6. textlayout = new QVBoxLayout;
    7.  
    8. real_chart = new Chart(this);
    9. synth_chart = new Chart(this);
    10. ident_chart = new Chart(this);
    11.  
    12. real_button = new QPushButton(this);
    13. real_button->setText("Real");
    14.  
    15. synth_button = new QPushButton(this);
    16. synth_button->setText("Synthetic");
    17.  
    18. ident_button = new QPushButton(this);
    19. ident_button->setText("Identify");
    20.  
    21. log = new QTextEdit(this);
    22. log->setReadOnly(true);
    23. log->setMaximumHeight(100);
    24.  
    25. textlayout->addWidget(log);
    26.  
    27. buttonlayout->addWidget(real_button);
    28. buttonlayout->addWidget(synth_button);
    29. buttonlayout->addWidget(ident_button);
    30. buttonlayout->addLayout(textlayout);
    31. }
    32.  
    33. //this is some sudo code for what the slots look like for each of the buttons
    34. void bla::buttonpush()
    35. {
    36. if(widget->isVisible() == false)
    37. {
    38. widget->show();
    39. resize(width,height);
    40. }
    41. else
    42. {
    43. widget->hide();
    44. resize(width,height);
    45. }
    46. }
    47.  
    48. //this is what this function does in a nutshell
    49. //works perfectly until the QTextEdit widget is inserted
    50. void bla::resize(int width, int height)
    51. {
    52. //get the height and width of the layout
    53. // divide the height by the number shown widgets
    54. //resize each widget that is shown to the correct width and height
    55. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 3rd August 2008 at 12:46. Reason: missing [code] tags

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.