qt1.3 and visual interface signals and slots

1 strand drawing

qt1.3 and visual interface signals and slots
qt1.3 and visual interface signals and slots
qt1.3 and visual interface signals and slots

2 Layout Manager
qt1.3 and visual interface signals and slots
qt1.3 and visual interface signals and slots

Layout is as follows:
qt1.3 and visual interface signals and slots

3 Partnership
functions: setting shortcut function, written & N, shortcut is ALT + N to jump to the label in the set position
qt1.3 and visual interface signals and slots

qt1.3 and visual interface signals and slots
qt1.3 and visual interface signals and slots

Tab order edit mode:
Phenomenon: pressing the tab key, the cursor moves in a fixed order

qt1.3 and visual interface signals and slots
qt1.3 and visual interface signals and slots
3 signals and slots
based QT design: signals and slots (Signal & Slot)
signals: signal of a specific situation be transmitted
grooves: response function of the transmit signal
when the signal is triggered, the slot function associated performed automatically: the relationship between the signal and the groove.
Signal slot associated with the use:
Connect (SENDER, the SIGNAL (Signal ()), Receiver, the SLOT (slot ()));
Connect () is a static function of class Object, but QObject is the base class for all Qt classes
sender: Send target signal
signal (): signal emitted (For brackets, there is a need to specify parameter parameter)
Receiver (): Subjects received signal
slot: the slot function (For brackets, there is a need to specify parameter parameter)
Connect (ui-> pushButton_3 , sIGNAL (clicked ()), this, sLOT (receiver ()));
automatically generates a signal and establish a connection with the groove:

qt1.3 and visual interface signals and slots
qt1.3 and visual interface signals and slots
qt1.3 and visual interface signals and slots

A third method of generating the signals and slots:
qt1.3 and visual interface signals and slots
qt1.3 and visual interface signals and slots

qt1.3 and visual interface signals and slots

Signals and slots Note:
a plurality of grooves may be connected to a signal function
Connect (ui-> pushButton_3, the SIGNAL (clicked ()), the this, the SLOT (Receiver ()));
Connect (ui-> pushButton_3, the SIGNAL (clicked ( )), this, sLOT (close ()));
execution order to establish a connection sequence when sequentially performing
a plurality of second signal connection with a groove
connect (ui-> rbtnBlue, sIGNAL ( clicked ()), this, sLOT (seclocr ()));
Connect (ui-> rbtnRed, the SIGNAL (clicked ()), the this, the SLOT (seclocr ()));
Connect (ui-> rbtnBlack, the SIGNAL (clicked ()), the this, the SLOT (seclocr () ));
any RadioButtton is pressed, will be executed seclocr ().
3 may be connected to a signal another signal
connect (ui-> pushButton_3, SIGNAL ( clicked ()), this, SLOT (reinfo ()));
when a signal is transmitted, the other signal is also emitted.
4 with the number of parameters generally require the type of signal must be consistent with the groove, but at least no less than the number of parameters of the signal grooves parameters. (The number of signal parameters> = number of grooves parameters).
5 is a signal when the signal transmitting groove, slot function executed immediately, for the following program is executed after completion.

Examples 2
qt1.3 and visual interface signals and slots
.h

private slots:
    void on_checkBox_clicked(bool checked);

    void on_checkBox_2_clicked(bool checked);

    void on_checkBox_3_clicked(bool checked);

void changecolor();

.c

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->radioButton,SIGNAL(clicked()),this,SLOT(changecolor()));
    connect(ui->radioButton_2,SIGNAL(clicked()),this,SLOT(changecolor()));
    connect(ui->radioButton_3,SIGNAL(clicked()),this,SLOT(changecolor()));
}

MainWindow::~MainWindow()
{
    delete ui;
}
//字体样式设置
void MainWindow::on_checkBox_clicked(bool checked)
{
    QFont font=ui->textEdit->font();
    font.setUnderline(checked);
    ui->textEdit->setFont(font);
}

void MainWindow::on_checkBox_2_clicked(bool checked)
{
    QFont font=ui->textEdit->font();
    font.setItalic(checked);
    ui->textEdit->setFont(font);
}

void MainWindow::on_checkBox_3_clicked(bool checked)
{
    QFont font=ui->textEdit->font();
    font.setBold(checked);
    ui->textEdit->setFont(font);
}
//改变颜色
void MainWindow::changecolor()
{
   QPalette pal=ui->textEdit->palette();
   if(ui->radioButton->isChecked())
   {
       pal.setColor(QPalette::Text,Qt::red);
   }
   else if(ui->radioButton_2->isChecked())
   {
       pal.setColor(QPalette::Text,Qt::blue);
   }
   else if (ui->radioButton_3->isChecked())
   {
       pal.setColor(QPalette::Text,Qt::black);
   }
   else {
       pal.setColor(QPalette::Text,Qt::black);
   }
   ui->textEdit->setPalette(pal);
}
   }
   ui->textEdit->setPalette(pal);
}

qt1.3 and visual interface signals and slots

operation result:

qt1.3 and visual interface signals and slots

Guess you like

Origin blog.51cto.com/14165014/2452752