Giter VIP home page Giter VIP logo

qt_login's Introduction

qt_login

Qt创建的界面默认都是包含标题栏的矩形框,这在实际项目开发中,自定义一些比较美观的界面中会显得比较单一,自定义的不规则界面效果如下:

图片

实际上不规则中的界面只是将底层透明化,只显示底层上面的子部件而已。

设置底层透明只需要在窗口的构造函数中调用:

  this->setAttribute(Qt::WA_TranslucentBackground, true);

隐藏标题栏:

this->setWindowFlags(Qt::FramelessWindowHint);

去除标题栏后恢鼠标按住移动窗口功能需要重载鼠标事件的三个函数:

// login_window.h
protected:
  void mousePressEvent(QMouseEvent *e);
  void mouseMoveEvent(QMouseEvent *e);
  void mouseReleaseEvent(QMouseEvent *e);
private:
  QPoint last; // 鼠标位置坐标
// login_window.cpp
void login_widget::mousePressEvent(QMouseEvent *e) { last = e->globalPos(); }

void login_widget::mouseMoveEvent(QMouseEvent *e) {
  int dx = e->globalX() - last.x();
  int dy = e->globalY() - last.y();
  last = e->globalPos();
  move(x() + dx, y() + dy);
}
void login_widget::mouseReleaseEvent(QMouseEvent *e) {
  int dx = e->globalX() - last.x();
  int dy = e->globalY() - last.y();
  move(x() + dx, y() + dy);
}

qt_login's People

Contributors

yangliuhui avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.