qt中如何去掉主窗口标题栏

有这样一个程序:

#include <QtGui/QApplication>

#include <qtextcodec.h>

#include <QtGui/QDialog>

#include <QtCore/QTimer>

#include "widget.h"

int main(int argc, char *argv[])

{

    QTextCodec::setCodecForTr(QTextCodec::codecForName("GB2312"));

    QApplication a(argc, argv);

    QDialog dialog;

    dialog.setStyleSheet(QString::fromUtf8("background-image: url(:/images/1.PNG);/n"

                                           "color: rgb(0, 255, 0);/n"

                                           "font: 75 16pt /"/345/256/213/344/275/223/";"));

    dialog.setGeometry(QRect(50, 50, 350, 250));               //可设置窗口显示的方位与大小

dialog.setWindowFlags(Qt::FramelessWindowHint);     //也是去掉标题栏的语句

Widget w;

    QTimer timer;

    QObject::connect(&timer, SIGNAL(timeout()), &w, SLOT(showNormal()));

    QObject::connect(&timer, SIGNAL(timeout()), &dialog, SLOT(accept()));

    timer.start(5000);

    dialog.exec();

    w.showNormal();       //  1、可更改的地方。

return a.exec();

}

Widget::Widget(QWidget *parent)

    : QWidget(parent)

{

    QMessageBox::StandardButton message;

    QApplication::setStyle(QStyleFactory::create("plastique"));

    QApplication::setPalette(QApplication::style()->standardPalette());

    ui.setupUi(this);

    connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(mountMessage()));

    connect(ui.pushButton_2, SIGNAL(clicked()), this, SLOT(umountMessage()));

    connect(ui.pushButton_3, SIGNAL(clicked()), this, SLOT(saveMessage()));

    connect(ui.pushButton_5, SIGNAL(clicked()), this, SLOT(adjustMessage()));

    connect(ui.pushButton_7, SIGNAL(clicked()), this, SLOT(about_usMessage()));

    connect(ui.pushButton_4, SIGNAL(clicked()), this, SLOT(stop_saveMessage()));

    connect(ui.pushButton_6, SIGNAL(clicked()), this, SLOT(touchMessage()));

    connect(ui.pushButton_8, SIGNAL(clicked()), this, SLOT(exitMessage()));

    mount_u();     //挂载U盘成功!

if( !have_video() ) {   //if have WebCam?

        message = QMessageBox::information(this, tr("摄像头未连接"),

tr("摄像头未连接,请连接摄像头。") );

    }

setWindowFlags(Qt::FramelessWindowHint);    /2、可更改的地方

setWindowTitle(tr("欢迎使用迷你监控器!"));

}

程序中更改两处显示主窗口的样式。

1、该处可设置窗口大小样式,有四种选择

w.show();                           实际大小

w.showEvent()                   自定义大小

w.showFullScreen();           全屏

w.showMaximized();           最大化

w.showMinimized();            最小化

w.showNormal();                 正常

2、该处是去掉窗口标题栏的语句

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值