Qt implements shadow forms similar to qq and qtqq shadow forms.

Source: Internet
Author: User

Qt implements shadow forms similar to qq and qtqq shadow forms.

# Ifndef BFWIDGET_H # define BFWIDGET_H # include <QWidget> # include <QMouseEvent> # include <QResizeEvent>/*** you can drag The * window to increase The shadow effect * @ brief The BFWidget class * /class BFWidget: public QWidget {Q_OBJECTpublic: explicit BFWidget (QWidget * parent = 0 ); /*** override Space layout settings * print the space to the central_widget * @ brief setLayout * @ param layout */void setLayout (QLayout * layout); signals: public slots: protected: void mousePressEvent (QMouseEvent * event); void mouseReleaseEvent (QMouseEvent * event); void mouseMoveEvent (QMouseEvent * event); // void resizeEvent (QResizeEvent * event); private: // display the content area QWidget * central_widget; QPoint move_point; // move the distance from bool mouse_press; // press the left mouse button}; # endif/BFWIDGET_H

<Pre name = "code" class = "cpp"> # include <QBoxLayout> # include <QPalette> # include <QGraphicsDropShadowEffect> # include <QDebug> # include <QSizePolicy> # include "bfwidget. h "BFWidget: BFWidget (QWidget * parent): QWidget (parent) {setWindowFlags (Qt: FramelessWindowHint); setAttribute (Qt: WA_TranslucentBackground); central_widget = new QWidget (); central_widget-> setSizePolicy (QSizePolicy: Expanding, QSizePolicy: Expanding); // you can stretch QPalette palette either horizontally or vertically. setBrush (QPalette: Background, QBrush (QColor (255,255,255); central_widget-> setPalette (palette); central_widget-> setAutoFillBackground (true ); optional * shadow_effect = new round (); shadow_effect-> setBlurRadius (10.0); shadow_effect-> setColor (QColor (0, 0, 0,100); shadow_effect-> setOffset (1.0 ); central_widget-> parameters (shadow_effect); Parameters * main_layout = new QVBoxLayout (); main_layout-> addWidget (central_widget, Qt: AlignCenter); main_layout-> addSpacing (0 ); main_layout-> setContentsMargins (5, 5, 5); QWidget: setLayout (main_layout);} void BFWidget: setLayout (QLayout * layout) {central_widget-> setLayout (layout );} void BFWidget: mousePressEvent (QMouseEvent * event) {// only move the left mouse button and change the size if (event-> button () = Qt: LeftButton) {mouse_press = true;} // window movement distance move_point = event-> globalPos ()-pos ();} void BFWidget: mouseReleaseEvent (QMouseEvent *) {mouse_press = false ;} void BFWidget: mouseMoveEvent (QMouseEvent * event) {// move the window if (mouse_press) {QPoint move_pos = event-> globalPos (); move (move_pos-move_point );}} // void BFWidget: resizeEvent (QResizeEvent * event) // {// QSize size = event-> size (); // central_widget-> setGeometry (5, 5, size. width ()-10, size. height ()-10); // qDebug () <central_widget-> rect ();//}


 

Qt allows you to record user names and passwords like qq in a login form.

The landlord wants to create a file to save the password value and whether to record the password value. The next time the file is opened (add the code in the showEvent function of the Dialog) initialize passWordLineEdit and jiluCheckBox
Value, which can be saved using QDataStream. QDeam contains instances. (^ ω ^) Come on

How does one transmit values between forms in QT? Tutorial

Use global variables, or use the signal-slot mechanism.
Put the parameters in the signal and slot parameters, and pass them over.

Give me some points...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.