×
Namespaces

Variants
Actions

Archived:How to use QSplitter and QTextEdit

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated.

Article Metadata
Tested with
Devices(s): Symbian emulator
Compatibility
Platform(s): Qt
Symbian
Platform Security
Signing Required: Self-Signed
Capabilities: None
Article
Keywords: QSplitter,QTextEdit
Created: kamaljaiswal (21 Dec 2008)
Last edited: hamishwillee (11 Oct 2012)

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.
}

Screenshot

Combcolor001.jpg

This page was last modified on 11 October 2012, at 04:14.
127 page views in the last 30 days.