I am trying to embed a simple "Hello World" text qml into a QMainWindow derived userdefined object.
In any possible idea that i tested, the text does not show up.
This is my object constructor code:
{
this->resize(1024, 768);
layout->setMargin(5);
layout->addWidget(topFiller);
layout->addWidget(bottomFiller);
this->setLayout(layout);
createActions();
createMenus();
QQmlEngine engine(this);
QQmlComponent component
(&engine,
QUrl::fromLocalFile("D:\\test.qml"),
this);
MainWindow::MainWindow() : QMainWindow ()
{
this->resize(1024, 768);
QWidget *topFiller = new QWidget;
topFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QWidget *bottomFiller = new QWidget;
bottomFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(5);
layout->addWidget(topFiller);
layout->addWidget(bottomFiller);
this->setLayout(layout);
createActions();
createMenus();
QQmlEngine engine(this);
QQmlComponent component(&engine, QUrl::fromLocalFile("D:\\test.qml"),this);
To copy to clipboard, switch view to plain text mode
This is my main app code:
int main(int argc, char *argv[])
{
MainWindow mw;
mw.show();
return a.exec();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow mw;
mw.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
This ist the QML file:
import QtQuick 2.0
Text {
text: "Hello world!" //a basic greeting
/*
We want this text to stand out from the rest so
we give it a large size and different font.
*/
font.family: "Helvetica"
font.pointSize: 24
}
import QtQuick 2.0
Text {
text: "Hello world!" //a basic greeting
/*
We want this text to stand out from the rest so
we give it a large size and different font.
*/
font.family: "Helvetica"
font.pointSize: 24
}
To copy to clipboard, switch view to plain text mode
Bookmarks