New Qwidget
-
Hi, can tell me pls anybody, whats wrong with this code :
@#include "mainwindow.h"
#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{ui->setupUi(this); QWidget *datawidget; datawidget = new QWidget(); datawidget->setAccessibleName("datawidget"); datawidget->setParent(ui->centralWidget); datawidget->resize(30,30); datawidget->setStyleSheet(" #datawidget { background-color:#000; } "); datawidget->show(); datawidget->setVisible(true);
}
MainWindow::~MainWindow()
{
delete ui;
}
@Thanks
-
Try this:
@MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{ui->setupUi(this); QWidget *datawidget = new QWidget( this ); ui->setCentralWidget( datawidget ); datawidget->setAccessibleName("datawidget"); datawidget->setStyleSheet(" #datawidget { background-color:#000; } ");
}
MainWindow::~MainWindow()
{
delete ui;
}@