I would like to delete row where QPushButton is clicked how it is possible to I think it is reasonable to use slots but how to do it don't know , if you have any ideas how to get a row of selected button please share, thanks.
It is my table
It is a code where i add rows to my QTableWidget
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
for(int i = 0; i<20;i++)
ui->tableWidget->insertRow(ui->tableWidget->rowCount());
QVector<QString>vec;
vec<<"first"<<"sec"<<"third"<<"for"<<"fif"<<"first"<<"sec"
<<"third"<<"for"<<"fif";
vec<<"first"<<"sec"<<"third"<<"for"<<"fif"<<"first"<<"sec"
<<"third"<<"for"<<"fif";
for(int i = 0; i<ui->tableWidget->rowCount();i++)
{
for(int j = 0; j<ui->tableWidget->columnCount();j++)
{
if(j == 0)
{
QWidget* pWidget = new QWidget();
QPushButton* btn_edit = new QPushButton();
btn_edit->setText("Remove");
QHBoxLayout* pLayout = new QHBoxLayout(pWidget);
pLayout->addWidget(btn_edit);
pLayout->setAlignment(Qt::AlignCenter);
pLayout->setContentsMargins(0, 0, 0, 0);
pWidget->setLayout(pLayout);
ui->tableWidget->setCellWidget(i, j, pWidget);
continue;
}
QTableWidgetItem*item = new QTableWidgetItem(vec[i]);
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
ui->tableWidget->setItem(i, j, item);
}
}
}
This task can be solved using the removeRow() method but before we must get the row. First of all we will connect all the buttons to a slot inside the loop as shown below:
*.h
private slots:
void onClicked();
*.cpp
[...]
QPushButton* btn_edit = new QPushButton();
btn_edit->setText("Remove");
connect(btn_edit, &QPushButton::clicked, this, &MainWindow::onClicked);
[...]
In the slot we can get the button that emits the signal through the sender() method, then we get QWidget parent (created with the name pWidget), this is the widget that is added to the QTableWidget and its position is relative to it, then we use the method indexAt() to get the QModelIndex associated with the cell, and this has the information of the row through the method row(). All of the above is implemented in the following lines:
void MainWindow::onClicked()
{
QWidget *w = qobject_cast<QWidget *>(sender()->parent());
if(w){
int row = ui->tableWidget->indexAt(w->pos()).row();
ui->tableWidget->removeRow(row);
ui->tableWidget->setCurrentCell(0, 0);
}
}
Note: The setCurrentCell() method is used to set the focus since the last cell that has it has been deleted.
The complete example can be found in the following link.
When you are creating QPushButton just add :
btn_delete = new QPushButton("Remove", ui->tableWidget);
btn_delete->setObjectName(QString("%1").arg(ui->tableWidget->rowCount()));
connect(btn_delete, SIGNAL(clicked()), this, SLOT(CellButtonDeleteClicked()));
And create function CellButtonDeleteClicked()
void CellButtonDeleteClicked()
{
// by this line I can get the sender of signal
QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
int row = pb->objectName().toInt();
ui->tableWidget->removeRow(row);
}
Related
I tried to build a simple GUI application. Then I got those warnings:
QLayout: Attempting to add QLayout "" to MainWindow "", which already has a layoutQWidget::setLayout: Attempting to set QLayout "" on MainWindow "", which already has a layout
I googled that you have to set central widget in MainWindow. And here is my implement which is still not working:
.h
class MainWindow : public QMainWindow
{
Q_OBJECT
QWidget *centralWidget;
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void setButtons();
...
private:
Ui::MainWindow *ui;
QPushButton *btn[9][9];
}
.cpp
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
centralWidget = new QWidget(this);
this->setCentralWidget(centralWidget);
...
}
void MainWindow::setButtons()
{
for(int i = 0; i < 9; i++) {
for(int j = 0; j < 9; j++) {
btn[i][j] = new QPushButton(this);
...
QVBoxLayout *vLayout = new QVBoxLayout(this);
vLayout->addWidget(btn[i][j]);
centralWidget->setLayout(vLayout);
}
}
}
After trying this, I still received the warning messages, how can I solve this problem?
Thanks.
Your code has two basic issues. Firstly, the statement...
QVBoxLayout *vLayout = new QVBoxLayout(this);
will instantiate a new QVBoxLayout with this as its parent. Since this is of type MainWindow * and MainWindow inherits from QMainWindow you are effectively calling QMainWindow::setLayout -- that's the source of the error message...
QLayout: Attempting to add QLayout "" to MainWindow "", which already
has a layout
Secondly, you're creating a new QVBoxLayout on each loop iteration. If you really do want the buttons vertically aligned in a layout try something like...
void MainWindow::setButtons ()
{
QVBoxLayout *vLayout = new QVBoxLayout(centralWidget);
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
btn[i][j] = new QPushButton;
...
vLayout->addWidget(btn[i][j]);
}
}
}
Each time the "Add Client" button is pressed - a minus button, the name of the client, a counter for the client and a plus button are added in a horizontal line to the gridLayout. I want to update the count (QLabel) when the plus/minus button is pressed.
Here is my code:
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QGridLayout>
#include <QLabel>
int row = 0;
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_pushButton_clicked()
{
QPushButton* minus_button = new QPushButton();
QPushButton* plus_button = new QPushButton();
minus_button->setText("-");
plus_button->setText("+");
QLabel* client_name = new QLabel(ui->lineEdit->text(), this);
QLabel* client_count = new QLabel("", this);
ui->gridLayout->addWidget(minus_button, row, 1, Qt::AlignTop|Qt::AlignHCenter);
ui->gridLayout->addWidget(client_name, row, 2, Qt::AlignTop|Qt::AlignHCenter);
ui->gridLayout->addWidget(client_count, row, 3, Qt::AlignTop|Qt::AlignHCenter);
ui->gridLayout->addWidget(plus_button, row++, 4, Qt::AlignTop|Qt::AlignHCenter);
connect(minus_button, SIGNAL(clicked(bool)), this, SLOT(minusCount()));
connect(plus_button, SIGNAL(clicked(bool)), this, SLOT(plusCount()));
}
void Widget::minusCount(){
//Here I want to somehow reference the client_count label which is in the same row
}
void Widget::plusCount(){
//Here I want to somehow reference the client_count label which is in the same row
}
EDIT: After Kevin's comment, here is the working code for anyone who may need it.
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QGridLayout>
#include <QLabel>
#include <QSignalMapper>
QSignalMapper* m_minusMapper;
QSignalMapper* m_plusMapper;
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
m_minusMapper = new QSignalMapper(this);
connect(m_minusMapper, SIGNAL(mapped(QWidget*)), this, SLOT(minusCount(QWidget*)));
m_plusMapper = new QSignalMapper(this);
connect(m_plusMapper, SIGNAL(mapped(QWidget*)), this, SLOT(plusCount(QWidget*)));
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_pushButton_clicked()
{
QPushButton* minus_button = new QPushButton();
minus_button->setObjectName("minus" + QString::number(row));
minus_button->setText("-");
QPushButton* plus_button = new QPushButton();
plus_button->setObjectName("plus" + QString::number(row));
plus_button->setText("+");
QLabel* client_name = new QLabel(ui->lineEdit->text(), this);
QLabel* client_count = new QLabel("0", this);
ui->gridLayout->addWidget(minus_button, row, 1, Qt::AlignVCenter|Qt::AlignHCenter);
ui->gridLayout->addWidget(client_name, row, 2, Qt::AlignVCenter|Qt::AlignHCenter);
ui->gridLayout->addWidget(client_count, row, 3, Qt::AlignVCenter|Qt::AlignHCenter);
ui->gridLayout->addWidget(plus_button, row++, 4, Qt::AlignVCenter|Qt::AlignHCenter);
connect(minus_button, SIGNAL(clicked()), m_minusMapper, SLOT(map()));
connect(plus_button, SIGNAL(clicked()), m_plusMapper, SLOT(map()));
m_minusMapper->setMapping(minus_button, client_count);
m_plusMapper->setMapping(plus_button, client_count);
}
void Widget::minusCount(QWidget *widget)
{
QLabel *client_count = qobject_cast<QLabel*>(widget);
QString initCount = client_count->text();
int newCount = initCount.toInt() - 1;
client_count->setText(QString::number(newCount));
}
void Widget::plusCount(QWidget *widget)
{
QLabel *client_count = qobject_cast<QLabel*>(widget);
QString initCount = client_count->text();
int newCount = initCount.toInt() + 1;
client_count->setText(QString::number(newCount));
}
Kevin's answer in principle is fine, but since we've got 2016 now and MSVC2010, gcc 4.7, and Clang 3.1 (and possibly earlier versions) support lambdas/C++11, I'd like to add a version without QSignalMapper:
static void minusCount(QLabel *label)
{
QString initCount = label->text();
int newCount = initCount.toInt() - 1;
label->setText(QString::number(newCount));
}
static void plusCount(QLabel *label)
{
QString initCount = label->text();
int newCount = initCount.toInt() + 1;
label->setText(QString::number(newCount));
}
void Widget::on_pushButton_clicked()
{
// ... add the labels and buttons, then:
connect(minus_button, &QPushButton::clicked,
client_count, [client_count]() { minusCount(client_count); });
connect(plus_button, &QPushButton::clicked,
client_count, [client_count]() { plusCount(client_count); });
}
Here the client_count label that the button click should change is captured in the lambda, and directly passed to the function handling it.
The minusCount and plusCount also can be static functions then, since they only operate on the label that is passed as an argument, so they are independent from any Widget instance.
The easiest way is to use a QSignalMapper
// in the constructor of your class
m_minusSignalMapper = new QSignalMapper(this);
connect(m_minusSignalMapper, SIGNAL(mapped(QWidget*)), this, SLOT(minusCount(QWidget*)));
m_plusSignalMapper = new QSignalMapper(this);
connect(m_plusSignalMapper, SIGNAL(mapped(QWidget*)), this, SLOT(plusCount(QWidget*)));
// in your button slot you connect to the respective mapper instead
connect(minus_button, SIGNAL(clicked()), m_minusMapper, SLOT(map()));
connect(plus_button, SIGNAL(clicked()), m_plusMapper, SLOT(map()));
// and you set up the mapping
m_minusMapper->setMapping(minus_button, client_count);
m_plusMapper->setMapping(plus_button, client_count);
// in the the two receiver slots, the argument is the label
void Widget::minusCount(QWidget *widget)
{
QLabel *client_count = qobject_cast<QLabel*>(widget);
}
I have a groupbox that contains some pushbuttons and sliders. I want that when I click on a button, a new groupbox that is the same with the former one should appear under the first one. Whenever I click on the button, same situation should happen dynamically. Since I need up to 32 groupbox like that, I don't want to put all groupboxes manually. So, how can I do this?
First off, a layout is highly recommended.
Here is an example (I have done this before). You can derive a class from QScrollArea, then set in the constructor the layouts you want to have.
In here a simple button called Add is in the window.
If you press it, a row gets added and initialized with default values (0, 0, 0) <- integers.
In the live program, I load the values from a file/database and initialize it then.
You may want to use different layout(s) and a different setup, but this should give you the idea. I'm sure you get where you want with a little more experimenting.
//Structure to keep track of the added widgets easier
struct ItemRow
{
ItemRow(QLineEdit *entry, QLineEdit *amount, QComboBox *box)
: m_Entry(entry)
, m_Amount(amount)
, m_Box(box)
{ }
ItemRow(void)
: m_Entry(nullptr)
, m_Amount(nullptr)
, m_Box(nullptr)
{ }
QLineEdit *m_Entry;
QLineEdit *m_Amount;
QComboBox *m_Box;
};
The class declaration.
class MyScrollArea : public QScrollArea
{
Q_OBJECT
public:
explicit MyScrollArea(QWidget *parent = 0);
~MyScrollArea();
//...
void OnAddButtonPressed(void);
void DrawButtonLayout(void);
void AddRow(int val1, int val2, int val3); //Use own parameters
private:
QVBoxLayout *m_LayoutFirstRow;
QVBoxLayout *m_LayoutSecondRow;
QVBoxLayout *m_LayoutThirdRow;
//...
QVBoxLayout *m_LayoutButton;
//...
QList<QPushButton*> m_Buttons;
QVector<ItemRow> m_ItemRows;
}
The implementation.
MyScrollArea::MyScrollArea(QWidget *parent) :
QScrollArea(parent),
ui(new Ui::MyScrollArea)
{
ui->setupUi(this);
setWidget(new QWidget);
setWidgetResizable(true);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
QHBoxLayout *mainLayout = new QHBoxLayout(this);
m_LayoutFirstRow = new QVBoxLayout();
m_LayoutSecondRow = new QVBoxLayout();
m_LayoutThirdRow = new QVBoxLayout();
m_LayoutButton = new QVBoxLayout();
widget()->setLayout(mainLayout);
mainLayout->addLayout(m_LayoutFirstRow);
mainLayout->addLayout(m_LayoutSecondRow);
mainLayout->addLayout(m_LayoutThirdRow);
mainLayout->addLayout(m_LayoutButton);
DrawButtonLayout();
}
RewardDialog::~RewardDialog()
{
delete ui;
}
void MyScrollArea::OnAddButtonPressed(void)
{
AddRow(0, 0, 0);
}
void MyScrollArea::DrawButtonLayout(void)
{
QPushButton *addBtn = new QPushButton("Add");
connect(addBtn, SIGNAL(clicked()), this, SLOT(OnAddButtonPressed()));
m_LayoutButton->addWidget(addBtn);
m_Buttons.push_back(addBtn); //Keep somewhere track of the button(s) if needed - example: put in QList (not the best approach though)
}
void MyScrollArea::AddRow(int val1, int val2, int val3)
{
QLineEdit *pEntry = new QLineEdit(QString::number(val1));
pEntry->setValidator(new QIntValidator());
QLineEdit *pAmount = new QLineEdit(QString::number(val2));
pAmount->setValidator(new QIntValidator());
QComboBox *pBox = new QComboBox();
InitComboBox(pBox, val3); //Initialize the combo-box (use connect if you wish) - code not included
m_LayoutFirstRow->addWidget(pEntry);
m_LayoutSecondRow->addWidget(pAmount);
m_LayoutThirdRow->addWidget(pBox);
ItemRow row;
row.m_Entry = pEntry;
row.m_Amount = pAmount;
row.m_Box = pBox;
m_ItemRows.push_back(row);
}
Leave a comment if something seems wrong, I put this together in Notepad++.
Note: The documentation-link is for QT4.8, as 5.3 is not available anymore, but my code is from version 5.3 too.
In one of my windows I made a button responsible for creating dynamic array of buttons. After they are made I can't make 'anul' button close the window
Here's the code
QWidget *centralWidget = new QWidget;
int licznik=1;
QString licz;
QString kolumny = ui->lineEdit->text();
QString wiersze = ui->lineEdit_2->text();
QPushButton *button[wiersze.toInt()][kolumny.toInt()];
QGridLayout *controlsLayout = new QGridLayout;
for(int i=0;i<wiersze.toInt();i++)
{
for(int j=0;j<kolumny.toInt();j++)
{
licz = QString::number(licznik);
licznik++;
button[i][j] = new QPushButton(licz);
button[i][j]->setCheckable(1);
controlsLayout->addWidget(button[i][j], i, j);
}
}
QPushButton *okej = new QPushButton("Zatwierdź");
QPushButton *anul = new QPushButton("Anuluj");
if(anul->isDown() == true)
this->close();
controlsLayout->addWidget(okej, wiersze.toInt(), 0);
controlsLayout->addWidget(anul, wiersze.toInt(), 1);
controlsLayout->setHorizontalSpacing(0);
controlsLayout->setVerticalSpacing(0);
centralWidget->setLayout(controlsLayout);
setCentralWidget(centralWidget);
I also tried to change this->close() with centralWidget->close()
This code is executed one time only.
if(anul->isDown() == true)
this->close();
What you want is to connect the clicked() signal of the button to a function (slot)
connect(anul, SIGNAL(clicked()), this,SLOT(close()))
Say I have a QHBoxLayout where there are 2 QTextEdits and between them a button with an arrow to the right. When you click on the button, the right-side QTextEdit gradually closes by moving the left border until it meets the right one. Simultaneously, the right border of the left QTextEdit takes the place which the right QTextEdit released. And after pressing on the button, the state of the system is coming to the former one.
EDIT: In order to organize this I have done the following:
1) In header file:
class MyWidget : public QWidget
{
Q_OBJECT
QTextEdit *m_textEditor1;
QTextEdit *m_textEditor2;
QPushButton *m_pushButton;
QHBoxLayout *m_layout;
int m_deltaX;
public:
MyWidget(QWidget * parent = 0);
~MyWidget(){}
private slots:
void closeOrOpenTextEdit2(bool isClosing);
};
2) In the source file:
MyWidget::MyWidget(QWidget * parent):QWidget(parent),m_deltaX(0)
{
m_pushButton = new QPushButton(this);
m_pushButton->setText(">");
m_pushButton->setCheckable(true);
connect(m_pushButton, SIGNAL(clicked(bool)), this, SLOT(closeOrOpenTextEdit2(bool)));
m_textEditor1 = new QTextEdit(this);
m_textEditor1->setText("AAAAA AAAAAAAAAAA AAAAAAAAAAA AAAAAAA AAAAAAAAAAA AAAAAAAAAAA AA");
m_textEditor2 = new QTextEdit(this);
m_layout = new QHBoxLayout;
m_layout->addWidget(m_textEditor1);
m_layout->addWidget(m_pushButton);
m_layout->addWidget(m_textEditor2);
setLayout(m_layout);
}
void MyWidget::closeOrOpenTextEdit2(bool isClosing)
{
QPropertyAnimation *animation1 = new QPropertyAnimation(m_textEditor2, "geometry");
QPropertyAnimation *animation2 = new QPropertyAnimation(m_pushButton, "geometry");
QPropertyAnimation *animation3 = new QPropertyAnimation(m_textEditor1, "geometry");
if(isClosing) //close the second textEdit
{
m_pushButton->setText("<");
QRect te2_1 = m_textEditor2->geometry();
m_deltaX = te2_1.width()-3;
QRect te2_2(te2_1.x()+m_deltaX, te2_1.y(), 3 ,te2_1.height());
QRect pb_1 = m_pushButton->geometry();
QRect pb_2(pb_1.x()+m_deltaX, pb_1.y(), pb_1.width() ,pb_1.height());
QRect te1_1 = m_textEditor1->geometry();
QRect te1_2(te1_1.x(), te1_1.y(), te1_1.width()+m_deltaX, te1_1.height());
//animation->setDuration(10000);
animation1->setStartValue(te2_1);
animation1->setEndValue(te2_2);
animation2->setStartValue(pb_1);
animation2->setEndValue(pb_2);
animation3->setStartValue(te1_1);
animation3->setEndValue(te1_2);
}
else //open
{
m_pushButton->setText(">");
QRect te2_1 = m_textEditor2->geometry();
QRect te2_2(te2_1.x()-m_deltaX, te2_1.y(), 3+m_deltaX ,te2_1.height());
QRect pb_1 = m_pushButton->geometry();
QRect pb_2(pb_1.x()-m_deltaX, pb_1.y(), pb_1.width() ,pb_1.height());
QRect te1_1 = m_textEditor1->geometry();
QRect te1_2(te1_1.x(), te1_1.y(), te1_1.width()-m_deltaX, te1_1.height());
//animation->setDuration(10000);
animation1->setStartValue(te2_1);
animation1->setEndValue(te2_2);
animation2->setStartValue(pb_1);
animation2->setEndValue(pb_2);
animation3->setStartValue(te1_1);
animation3->setEndValue(te1_2);
}
animation1->start();
animation2->start();
animation3->start();
}
EDIT:
And I have the following problem:
When I close the second QTextEdit (by clicking on the button) and resize the MyWidget, then the QTextEdit restores its state (but it should stay closed of course). How can I solve this problem?
Please provide me with a code snippet.
Qt's Animation framework sounds like a good place to start. You could just try to follow their tutorials, adapting for you use case. I have used it already, and it seemed quite straight forward.
1) You could replace your button with a vertical layout, place the button inside this layout and finally add a vertical spacer below the button (in same the layout).
...
QVBoxLayout* m_buttonLayout = new QVBoxLayout();
m_layout = new QHBoxLayout();
m_layout->addWidget(m_textEditor1);
m_layout->addLayout(m_buttonLayout);
m_layout->addWidget(m_textEditor2);
m_buttonLayout->addWidget(m_pushButton);
m_buttonLayout->addItem( new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding) );
2) I guess you could (and should) animate widget's maximumSize (or just maximumWidth) property and let the layout take care of calculating actual geometries. This would also simplify your calculations. E.g.
QPropertyAnimation *animation1 = new QPropertyAnimation(m_textEditor2, "maximumWidth");
QPropertyAnimation *animation2 = new QPropertyAnimation(m_textEditor, "maximumWidth");
if (isClosing)
{
int textEdit2_start = m_textEditor2->maximumWidth();
int textEdit2_end = 0;
int textEdit_start = m_textEditor->maximumWidth();
int textEdit_end = textEdit_start + textEdit2_start;
animation1->setStartValue(textEdit2_start);
...
}
Also, now you don't have to animate buttons geometry at all (assuming that you have set fixed size to it).
PS. I didn't compile codes so there might be minor errors but you should get the idea.
Here what I wanted:
Header file
class MyWidget : public QWidget
{
Q_OBJECT
QTextEdit *m_textEditor1;
QTextEdit *m_textEditor2;
QPushButton *m_pushButton;
QHBoxLayout *m_layout;
QVBoxLayout *m_buttonLayout;
int m_deltaX;
bool m_isClosed;
public:
MyWidget(QWidget * parent = 0);
~MyWidget(){}
void resizeEvent( QResizeEvent * event );
private slots:
void closeOrOpenTextEdit2(bool isClosing);
};
Source file
MyWidget::MyWidget(QWidget * parent):QWidget(parent),m_deltaX(0)
{
m_pushButton = new QPushButton(this);
m_pushButton->setText(">");
m_pushButton->setCheckable(true);
m_pushButton->setFixedSize(16,16);
connect(m_pushButton, SIGNAL(clicked(bool)), this, SLOT(closeOrOpenTextEdit2(bool)));
m_textEditor1 = new QTextEdit(this);
m_textEditor1->setText("AAAAA AAAAAAAAAAA AAAAAAAAAAA AAAAAAA AAAAAAAAAAA AAAAAAAAAAA AA");
m_textEditor2 = new QTextEdit(this);
m_buttonLayout = new QVBoxLayout();
m_buttonLayout->addWidget(m_pushButton);
m_buttonLayout->addItem( new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding) );
m_layout = new QHBoxLayout;
m_layout->addWidget(m_textEditor1, 10);
m_layout->addSpacing(15);
m_layout->addLayout(m_buttonLayout);
m_layout->setSpacing(0);
m_layout->addWidget(m_textEditor2, 4);
setLayout(m_layout);
resize(800,500);
}
void MyWidget::closeOrOpenTextEdit2(bool isClosing)
{
m_isClosed = isClosing;
QPropertyAnimation *animation1 = new QPropertyAnimation(m_textEditor2, "maximumWidth");
if(isClosing) //close the second textEdit
{
m_textEditor2->setMaximumWidth(m_textEditor2->width());
int textEdit2_start = m_textEditor2->maximumWidth();
m_deltaX = textEdit2_start;
int textEdit2_end = 3;
animation1->setDuration(500);
animation1->setStartValue(textEdit2_start);
animation1->setEndValue(textEdit2_end);
m_pushButton->setText("<");
}
else //open
{
int textEdit2_start = m_textEditor2->maximumWidth();
int textEdit2_end = m_deltaX;
animation1->setDuration(500);
animation1->setStartValue(textEdit2_start);
animation1->setEndValue(textEdit2_end);
m_pushButton->setText(">");
}
animation1->start();
}
void MyWidget::resizeEvent( QResizeEvent * event )
{
if(!m_isClosed)
m_textEditor2->setMaximumWidth( QWIDGETSIZE_MAX );
}