QString str = ui->label->text();
#include <QApplication>#include <QVBoxLayout>#include <QLabel>#include <QSpinBox>#include <QSlider>int main(int argc, char *argv[]){ QApplication app(argc, argv); QLabel *label = new QLabel; QSpinBox *spinBox = new QSpinBox; spinBox->setMinimum(0); spinBox->setMaximum(100); spinBox->setSingleStep(5); QSlider *slider = new QSlider(Qt::Horizontal); slider->setRange( spinBox->minimum(), spinBox->maximum() ); slider->setSingleStep(10); slider->setTickPosition(QSlider::TicksBelow); slider->setTickInterval(10); QObject::connect( spinBox, SIGNAL(valueChanged(int)), label, SLOT(setNum(int)) ); QObject::connect( spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)) ); QObject::connect( slider, SIGNAL(valueChanged(int)), label, SLOT(setNum(int)) ); QObject::connect( slider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int)) ); spinBox->setValue(20); QWidget window; QVBoxLayout* mainLayout = new QVBoxLayout(&window); mainLayout->addWidget(label); mainLayout->addWidget(spinBox); mainLayout->addWidget(slider); window.show(); return app.exec();}
####################################################################### Automatically generated by qmake (2.01a) ?? 30. ??? 15:45:50 2008######################################################################TEMPLATE = appTARGET = DEPENDPATH += .INCLUDEPATH += .# InputSOURCES += slider.cpp
private slots: void on_pushButton_clicked();
void MainWindow::on_pushButton_clicked(){ ui->printText("12345-qwerty"); // эту строку добавил}
// эти строки добавлены в класс Ui_MainWindowvoid printText(QString str) { Ui_MainWindow::lineEdit->setText(str); }
WARNING! All changes made in this file will be lost when recompiling ui file!
connect( myButton, SIGNAL(clicked()), myLineEdit, SLOT(setText(QString &)) );