QString設置參數QPushButton&QFocusFrame

QString("Frame's button %1").arg(i)
#include "widget.h"
#include <QtWidgets/QPushButton>
#include <QtWidgets/QFocusFrame>

/*
QFocusFrame能夠控制其餘控件外的Paintable區域。例如在控件外使用
外層線。使用QFocusFrame在QPushButton控件外繪製外層線
*/
Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
   QPushButton *btn = new QPushButton(QString("Frame's button"), this);
   btn->setGeometry(10, 30, 300, 40);

   QFocusFrame *btn_frame = new QFocusFrame(this);
   btn_frame->setWidget(btn);
  // btn_frame->setAutoFillBackground(true);

   connect(btn, SIGNAL(clicked()), this, SLOT(btn_click()));
   connect(btn, SIGNAL(pressed()), this, SLOT(btn_pressed()));
   connect(btn, SIGNAL(released()), this, SLOT(btn_released()));

}

/*
Button Pressed
Button Relased
Button Click
單擊按鈕式,最早執行Pressed事件;釋放按鈕Relased事件
Click事件處理Pressed&Relased事件併發送信號
*/
void Widget::btn_click()
{
    qDebug("Button Click");
}

void Widget::btn_pressed()
{
    qDebug("Button Pressed");
}

void Widget::btn_released()
{
    qDebug("Button Relased");
}

Widget::~Widget()
{

}

相關文章
相關標籤/搜索