[solved] opening a widget with qml file included
-
@
prima::prima(QWidget *parent) :
QWidget(parent)
{
QDeclarativeView *primaSchermata = new QDeclarativeView(this);
primaSchermata->setSource(QUrl::fromLocalFile("qml/OpenOrario/main.qml"));
primaSchermata->show();QObject *obj = primaSchermata->rootObject(); move(0,0); showMaximized(); QObject::connect(obj, SIGNAL(signal_nuovoClicked()), this, SLOT(nuovo()));
}
void prima::nuovo()
{
seconda s;
}
@@
seconda::seconda(QWidget *parent) :
QWidget(parent)
{
QDeclarativeView *secondaview = new QDeclarativeView(this);
secondaview->setSource(QUrl::fromLocalFile("qml/OpenOrario/seconda.qml"));
secondaview->show();move(0,0); showMaximized();
}
@the second window appears and desappears in a moment...
[edit : typo fixed in title, Eddy]
-
Make your "seconda" instance variable a member of your prima class and use new to create your seconda instance. This is pretty basic C++ stuff.
@
class prima ...
{
...
private:
seconda *m_seconda;
}void prima::nuovo()
{
m_seconda = new seconda(this); // create it on the heap, so it doesn't go out of scope
}
@ -
[quote author="spode" date="1317321543"]@
void prima::nuovo()
{
seconda s;
s.show();
close();
here:
goto here;
}
@the window stops working...[/quote]
Oh, that's just so wrong in so many ways... see above.
But let's step through the code...
@
seconda s; // This creates the object
s.show(); // This shows it. It DOES NOT BLOCK AND WAIT FOR THE WIDGET TO CLOSE
close(); // This closes the window immediately.
@Here's an exercise. What do you think the
@
here:
goto here;
@
code does? (Hint... tight, infinite loop)