Results 1 to 5 of 5

Thread: Add QTextEdit in a Help Menu

  1. #1
    Join Date
    May 2012
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Add QTextEdit in a Help Menu

    I have a Help Menu and under the help menu i have help, and about. Now when the user clicks the help menu a new window should pop out containing all the help details of the program.

    I have this code so far for the help action.

    Qt Code:
    1. void MainWindow::on_action_Help_triggered()
    2. {
    3. ui->newWindow = new QWidget();
    4. ui->newWindow->show();
    5. ui->newWindow->setFixedSize(350, 200);
    6. ui->newWindow->setWindowTitle("Help Menu");
    7.  
    8. QTextEdit *textEdit = new QTextEdit;
    9. textEdit->setText("sample");
    10. textEdit->show();
    11.  
    12. }
    To copy to clipboard, switch view to plain text mode 

    Unfortunately my code is showing me this. 4 windows, 2 for the help menu and 2 for the textEdit.
    Screenshot from 2012-06-07 21:19:29.png

    How can I connect the textEdit to the widget so that it will only be in that widget and not as a separate window?And why is it showing two instances of the help menu and the textEdit when I don't even have a loop to show them twice?


    Added after 6 minutes:


    So to make my life a little bit easier i just decided to do this

    Qt Code:
    1. void MainWindow::on_action_Help_triggered()
    2. {
    3. QTextEdit *textEdit = new QTextEdit;
    4. textEdit->setFixedSize(350, 200);
    5. textEdit->setWindowTitle("Help Menu");
    6. textEdit->setReadOnly(TRUE);
    7. textEdit->setText("sample");
    8. textEdit->show();
    9. }
    To copy to clipboard, switch view to plain text mode 

    But for some reason how come when i click the help option it's showing me two instances of textEdit?
    Screenshot from 2012-06-07 21:19:29.png
    Last edited by stbb24; 7th June 2012 at 14:42.

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Add QTextEdit in a Help Menu

    widgets appear in their own window unless they have a parent.

    you can set parents via 2 ways - directly set parent*, or add widget to a layout, then set the layout on the parent widget.

    If your window shows up twice, it will be because you have connected the signal/slot twice.


    *this can be done two ways - by constructor parent argument or by setParent()
    Last edited by amleto; 7th June 2012 at 15:46.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    May 2012
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Add QTextEdit in a Help Menu

    Thanks! I already got it thanks for the clue about the connect/slot signals

    Different question...

    How can I display my program in a specific area? Because everytime i run the program sometimes it displays in the left side, right side, bottom side of my monitor. So how can I set it's display position in a fix area so that everytime I run it, it will only display itseld the area that I specified (for ex: in the center of the monitor)

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Add QTextEdit in a Help Menu

    widget->move(x,y);

    first google result:
    http://www.qtforum.org/article/14204...is-called.html
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    Join Date
    May 2012
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Add QTextEdit in a Help Menu

    Thanks amleto it work

Similar Threads

  1. Replies: 1
    Last Post: 18th May 2012, 11:36
  2. extend the standard context menu of qtextedit
    By cai in forum Qt Programming
    Replies: 9
    Last Post: 10th November 2011, 12:16
  3. Replies: 1
    Last Post: 4th November 2011, 11:25
  4. QMenu context menu on QTextEdit
    By johnmauer in forum Qt Programming
    Replies: 0
    Last Post: 10th January 2011, 21:48
  5. Replies: 1
    Last Post: 16th February 2007, 07:22

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.