1

I have developed an application in Qt with QMainWindow as a main Widget, and added Mdiarea I needed for adding QMdieSubWindows.

I want know how to have a logging area like in Qt Creator.

My log text is basically what is going on. As

Started the optimizer ... File is saved ... The file is not loaded ... and etc.

I thought of adding a QPlainTextEdit or a QTextEdit, and just append text to them.

I wrote this in my QMainWindow.cpp:

QPlainText* mydebugger = new QPlainText(this);
mydebugger.appendPlaintext("Debugger started");
mydebugger.show();

But this is showing the plainText over my Menu in QMainWindow;

I would like to have it on the bottom, above my StatusBar.

I would like to ask now:

  1. QPlainTextEdit or QTextEdit: which one is better for my task? I need only appending the text, and maybe highlighting, and coloring the text.

  2. How to get the Q(Plain)TextEdit as for example in QtCreator at the bottom with fixed position and fixed width?

I tried to create an MdiSubWindow and add the plaintext widget into it, and show it. It works as I wanted, and I can add text in it. But I can not still make fixed at the bottom. Any ideas?

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
amol01
  • 1,823
  • 4
  • 21
  • 35

1 Answers1

2
  1. If you want colour and other formatting options, QTextEdit is your way to go. QPlainTextEdit does not allow formatting.

  2. You're better off using a QDockWidget than a QMdiSubWindow. You can then dock your logger at the bottom of your main window.

RobbieE
  • 4,280
  • 3
  • 22
  • 36
  • Hi thanks. Can I still use QDockWidget with QMdiArea or should it be only within QMainWindow? I need MdiArea to show several QMdiSubWindows. – amol01 Jun 20 '14 at 16:15
  • The MDI area is where all MDI subwindows live. It is usually set as the central widget on `QMainWindow` if you want to have a MDI look and feel. The dock widgets will be docked in one of the four sides around the central widget. If you look at the documentation for `QMainWindow`, you'll get a good explanation on how to do this. – RobbieE Jun 20 '14 at 16:30
  • Thanks. Awesome idea to use DockWidget. It is exactly what I wanted. – amol01 Jun 20 '14 at 16:35