Qt下等待對話方塊的設計

2021-07-02 18:53:16 字數 1128 閱讀 9330

在qt程式經常長時間操作時採用乙個等待對話方塊來提示使用者正在操作。

qt有標準的qprocessdialog 能部分實現這個功能,但是缺點是要計算進度,二是使用者可以中途取消。所以一般我們採用自定義對話方塊實現這個功能。

其中的思路和素材**於 但這個只乙個思路演示,我這裡實現是完整**,增加了圓角矩形背景

使用如下動畫gif

這裡還有乙個gif 動畫的製作和素材庫

#ifndef qwaitdialog_h

#define qwaitdialog_h

#include

#include

#include

#include

class qwaitdialog : public qdialog

;#endif // qwaitdialog_h

qwaitdialog.cpp

#include "qwaitdialog.h"

qwaitdialog::qwaitdialog(qwidget *parent,const qstring &title) :

qdialog(parent)

qwaitdialog::~qwaitdialog()

其中,是我加的**,主要實現用qss實現圓角視窗。這裡不在對話方塊採用border-radius是因為這個屬性對頂層視窗無效,只能先設對話方塊背景為透明,再上面鋪乙個圓角的qframe,所有控制項是加在

this->setwindowflags(qt::framelesswindowhint | qt::dialog);

this->setstylesheet(「background-color:transparent;」);

background = new qframe(this);

background->setstylesheet(「background-color: rgb(55, 135,215);border-radius:10px;」);

最終效果

Qt等待對話方塊結束

接觸qt一年左右,還算個新手。剛剛一直糾結於如何在等待qt對話方塊結束後獲得對話方塊的資料,現在終於搞定了。imageselection imselection new imageselection this if imselection exec qdialog accepted qstring ...

Qt 對話方塊

1.qt 中使用qdialog 類實現對話方塊。就像主視窗一樣,我們通常會設計乙個類繼承 qdialog qdialog 及其子類,以及所有 qt dialog 型別的類 的對於其 parent 指標都有額外的解釋 如果 parent 為null 則該對話方塊會作為乙個頂層視窗,否則則作為其父元件的...

Qt 對話方塊

1.qdialog 類是對話方塊視窗的基類。對話方塊視窗是乙個頂級視窗,通常用作短期任務,或 者是與使用者的簡短會話等場合。2.對話方塊可以分為模態對話方塊和非模態對話方塊。所謂模態對話方塊就是在其沒有被關閉之前,使用者不能與同乙個應用程式的其他視窗進行互動,直到該對話方塊關閉。奪取焦點 對於非模態...