Ich versuche, Inhalt zu einem QWidget
hinzuzufügen, aber nichts zeigt jemals. Das Fenster erscheint leer und leer, ohne Inhalt, den ich hinzufügen möchte.Inhalt wird nicht hinzugefügt zeigt in einem QWidget
mainwindow.cpp
#include "mainwindow.h"
#include <QApplication>
MainWindow::MainWindow(QWidget *parent) :
QWidget(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint)
{
mainWin = new QWidget();
// Create the button, make "this" the parent
m_button = new QPushButton("My Button", this);
// set size and location of the button
m_button->setGeometry(QRect(QPoint(100, 100), QSize(200, 50)));
hlayout = new QHBoxLayout;
hlayout -> addWidget(m_button);
mainWin -> setLayout(hlayout);
}
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QHBoxLayout>
class MainWindow : public QWidget
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
private:
QPushButton *m_button;
QHBoxLayout *hlayout;
};
#endif
main.cpp
#include "mainwindow.h"
#include <QtPlugin>
#include <QApplication>
#include <QDesktopWidget>
Q_IMPORT_PLUGIN(BasicToolsPlugin)
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow window;
QDesktopWidget dw;
int x=dw.width()*0.7;
int y=dw.height()*0.7;
window.setFixedSize(x, y);
window.show();
return app.exec();
}
Was ist es, das ich bin m oder falsch machen?
Vielen Dank im Voraus.