[Interest] QTextEdit not resizing with QFormLayout
Diego Iastrubni
diegoiast at gmail.com
Tue May 8 15:15:17 CEST 2012
Use QtDesigner you will see what is done.
See also the documentation for QMainWindow::setCentralWidget().
On Tue, May 8, 2012 at 11:43 AM, Sujan Dasmahapatra <sdh at lmwindpower.com>wrote:
> //mainwindow.h****
>
> QWidget *widget;****
>
> QPushButton *button;****
>
> QTextEdit *edit1;****
>
> QFormLayout *formL;****
>
> ** **
>
> MainWindow::MainWindow(QWidget *parent):QMainWindow(parent)****
>
> {****
>
> setGeometry(0,0,800,600);****
>
> ** **
>
> widget = new QWidget(this);****
>
> widget->resize(size());****
>
> ** **
>
> button = new QPushButton("Click me!!",widget);****
>
> button->setGeometry(5,5,100,25);****
>
> button->setFixedSize(100,25);****
>
> button->show();****
>
> ** **
>
> edit1 = new QTextEdit(widget);****
>
> edit1->setGeometry(5,35,widget->width()-10, widget->height()-40);****
>
> edit1->show();****
>
> ** **
>
> formL = new QFormLayout(widget);****
>
> formL->addWidget(button);****
>
> formL->addWidget(edit1);****
>
> widget->setLayout(formL);****
>
> widget->show();****
>
> }****
>
> ** **
>
> With this code, my textedit(edit1) is not moving vertically, although
> it’s moving horizontally when resizing the mainwindow. Edit1’s initial
> height is also less. I want the initial height of the edit should be 5 unit
> less from the bottom and 35 units less from the top as there’s a pushbutton
> for 25 units at the top. And edit1 should also resize vertically.****
>
> ** **
>
> Pushbutton is working fine I have set it to be fixed size so it is ok.
> Edit1 should be resizing according to the mainwindow both vertically and
> horizontally.****
>
> ** **
>
> ** **
>
> ** **
>
>
> *Sent:* Tuesday, May 08, 2012 1:53 PM
> *To:* Sujan Dasmahapatra
> *Cc:* interest at qt-project.org
> *Subject:* Re: [Interest] QTextEdit not resizing with QFormLayout****
>
> ** **
>
> Use layouts, not absolute positioning. Read the docs about it.****
>
> ** **
>
> ** **
>
> On Tue, May 8, 2012 at 11:13 AM, Sujan Dasmahapatra <sdh at lmwindpower.com>
> wrote:****
>
> Please check this code snippet, with this when I resize the mainwindow, my
> textedit is not resizing. What could be the problem pls help.****
>
> ****
>
> //mainwindow.h****
>
> QPushButton *button;****
>
> QTextEdit *edit;****
>
> QFormLayout *formL;****
>
> ****
>
> //mainwindow.cpp****
>
> MainWindow::MainWindow(QWidget *parent):QMainWindow(parent)****
>
> {****
>
> setGeometry(0,0,800,600);****
>
> ****
>
> button = new QPushButton("Click me!!",this);****
>
> button->setGeometry(5,5,100,25);****
>
> button->show();****
>
> ****
>
> edit1 = new QTextEdit(this);****
>
> edit1->setGeometry(5, 35, width()-10, height()-40);****
>
> edit1->show();****
>
> ****
>
> formL = new QFormLayout;****
>
> formL->addRow(("&Name:"), edit1);****
>
> setLayout(formL);****
>
> }****
>
> ****
>
> Thanks sujan****
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest****
>
> ** **
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120508/709697fc/attachment.html>
More information about the Interest
mailing list