#include <QApplication>
#include <QPainter>
#include <QPixmap>
#include <QSplashScreen>
#include <QWidget>
#include "SplashScreen.h"
SplashScreen
::SplashScreen(const QPixmap &pixmap,Qt
::WindowFlags ) : QWidget(pixmap ,
0,Qt
::FramelessWindowHint,
Qt::WindowStaysOnTopHint,
Qt::Tool)
//Qt::WStyle_Customize ,Qt:: WStyle_NoBorder ,Qt:: WStyle_StaysOnTop ,Qt:: WStyle_Tool)
{
pix.load("image.jpg");
//setBackgroundPixmap(pix);
resize( pix.size() );
move( scr.center() - rect().center() );
show();
repaint();
}
void SplashScreen::repaint()
{
qApp->processEvents();
}
void SplashScreen::finish()
{
close();
}
void SplashScreen
::showMessage(const QString &message,
int alignment =Qt::AlignLeft,
const QColor &color
= Qt
:: white)
{
painter.setPen(Qt::blue);
painter.
setFont(QFont("Arial",
30));
r.setRect( r.x() + 10, r.y() + 10, r.width() - 20, r.height() - 20 );
painter.drawText( r, alignment, message );
// setBackgroundPixmap( textPix );
painter.background(textPix);
repaint();
}
#include <QApplication>
#include <QPainter>
#include <QPixmap>
#include <QSplashScreen>
#include <QWidget>
#include "SplashScreen.h"
SplashScreen::SplashScreen(const QPixmap &pixmap,Qt::WindowFlags ) :
QWidget(pixmap , 0,Qt::FramelessWindowHint,
Qt::WindowStaysOnTopHint,
Qt::Tool)
//Qt::WStyle_Customize ,Qt:: WStyle_NoBorder ,Qt:: WStyle_StaysOnTop ,Qt:: WStyle_Tool)
{
QPixmap pix;
pix.load("image.jpg");
//setBackgroundPixmap(pix);
resize( pix.size() );
QRect scr = QApplication::desktop()->geometry();
move( scr.center() - rect().center() );
show();
repaint();
}
void SplashScreen::repaint()
{
QWidget::repaint();
qApp->processEvents();
}
void SplashScreen::finish()
{
close();
}
void SplashScreen::showMessage(const QString &message,
int alignment =Qt::AlignLeft,
const QColor &color = Qt:: white)
{
QPixmap textPix = pix;
QPainter painter( &textPix, this );
painter.setPen(Qt::blue);
painter.setFont(QFont("Arial", 30));
QRect r = rect();
r.setRect( r.x() + 10, r.y() + 10, r.width() - 20, r.height() - 20 );
painter.drawText( r, alignment, message );
// setBackgroundPixmap( textPix );
painter.background(textPix);
repaint();
}
To copy to clipboard, switch view to plain text mode
Bookmarks