М-да действительно написал прогу
что-то keyPressEvent (QKeyEvent * event)
не срабатывает
#ifndef TRANSPORTTXT_H
#define TRANSPORTTXT_H
#include <QtGui/QWidget>
#include "ui_transporttxt.h"
#include "QKeyEvent"
#include "QLineEdit"
#include "QLabel"
#include "QString"
#include "QDebug"
class transportTXT : public QWidget
{
Q_OBJECT
public:
QString string;
public:
transportTXT(QWidget *parent = 0);
~transportTXT();
public slots:
void get_text(const QString&);
signals:
void sg_txt(const QString&);
protected:
void keyPressEvent ( QKeyEvent * event );
void resizeEvent(QResizeEvent* event);
private:
Ui::transportTXTClass ui;
};
#endif // TRANSPORTTXT_H
#include "transporttxt.h"
transportTXT::transportTXT(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
connect(ui.lineEdit,SIGNAL(textChanged (const QString& )),this,SLOT(get_text(const QString&)));
//connect(this,SIGNAL(sg_txt(const QString&)),ui.label,SLOT(setText(const QString&)));
}
transportTXT::~transportTXT()
{
}
void transportTXT::resizeEvent(QResizeEvent* event)
{
ui.label->setText(string);
qDebug()<<"string = "<<string;
event->accept();
}
void transportTXT:: keyPressEvent (QKeyEvent * event)
{
if(event->key()==Qt::Key_0)
{
ui.label->setText(string);
//qDebug()<<"string = "<<string;
//connect(this,SIGNAL(sg_txt(const QString&)),ui.label,SLOT(setText(const QString&)));
event->accept();
}
}
void transportTXT::get_text(const QString &str )
{
string = str;
qDebug()<<"string = "<<string;
}