Hey,
this is my file "Zeichenfläche.cpp" (in english Viewport.cpp)
-----------------------------------------------------------------------------------------------------
#include "Zeichenflaeche.h"
Zeichenflaeche::Zeichenflaeche(QMainWindow *parent):QWidget(parent)
{
erstelleZeichenflaeche(parent);
}
//create Widget / Viewport
void Zeichenflaeche::erstelleZeichenflaeche(QMainWindow *parent)
{
Zeichenfl = new QWidget(parent);
Zeichenfl->setWindowFlags(Qt::Window);
Zeichenfl->setWindowTitle("Viewport");
Zeichenfl->show();
}
//Paintevent
void Zeichenflaeche:aintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::blue);
painter.translate(0, rect().height());
painter.drawPie(QRect(-35, -35, 70, 70), 0, 90 * 16);
}
--------------------------------------------------------------
The window is being "startet" in the file mainwindow.cpp, now just showing the necessary code:
----------------------------------------------------------------
//"Wrapper" for the Mainwindow-Functions
Hauptfenster::Hauptfenster()
{
Toolb = new Toolbar(this);
-----> Zeichenfl = new Zeichenflaeche(this); <-------------- //creation of the Viewport
setCentralWidget(Toolb);
erstelleAktionen();
erstelleIcons();
}
---------------------------------------------------------------
The Painting is actually happening in the Main-window, although it is supposed to happen in the Viewport. Anymore code required? Hope it made everything a little more clear :-)
Best
EDIT: Just to make it really clear: As far as I can see the problem is, that I can't really tell the Paintevent to Paint anywhere else than in the Main Window, which would be really handy :-)
Bookmarks