Archived:How to use QSplitter and QTextEdit
Article Metadata
Tested with
Devices(s): Emulator
Compatibility
Platform(s): S60 3rd Edition, S60 5th Edition
Article
Keywords: QSplitter,QTextEdit
Created: ()
Last edited: fasttrack
(12 Sep 2009)
Contents |
Various functions for QSplitter
- To insert the widget in splitter at a specific position
splitter.insertWidget( 3, button );
- To set the Orientation of Qsplitter
QSplitter splitter(Qt::Vertical/Qt::Horizontal);
Various functions for QTextEdit
- To set font Italic in QTextBox.
QTextEdit *editor1 = new QTextEdit; editor->setFontItalic(1);
- To set the Document title.For a newly-created, empty document, this property contains an empty string.
textEdit->setDocumentTitle("Hello");
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
QTextEdit *editor1 = new QTextEdit;
QTextEdit *editor2 = new QTextEdit;
QTextEdit *editor3 = new QTextEdit;
A QSplitter is a widget that contains other widgets. The child widgets of a QSplitter widget are automatically placed side by side (or one below the other) in the order in which they are created, with splitter bars between adjacent widgets.
QSplitter splitter(Qt::Horizontal);
splitter.addWidget(editor1);
splitter.addWidget(editor2);
splitter.addWidget(editor3);
Make widget visible.
splitter.show();
Source Code
#include "splitter.h"
#include<QSplitter>
#include<QTextEdit>
#include<QHBoxLayout>
splitter::splitter(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *layout=new QHBoxLayout(this);
QTextEdit *editor1 = new QTextEdit("Qt rocks",this);
QTextEdit *editor2 = new QTextEdit("for",this);
QTextEdit *but1=new QTextEdit("hello",this);
QSplitter splitter(Qt::Vertical);
splitter.addWidget(editor1);
splitter.addWidget(editor2);
splitter.addWidget(but1);
layout->addWidget(editor1);
layout->addWidget(editor2);
layout->addWidget(but1);
setStyleSheet("* { background-color:rgb(0,0,0);color:rgb(255,255,255); padding: 7px}}");
setLayout(layout);
showMaximized();
}
splitter::~splitter()
{
// No need to delete any object that has a parent which is properly deleted.
}


