[SOLVED]How to promote QMdiArea in designer?
-
Hi All,
How can I promote QMdiArea widget in Qt Designer ?
I didn't find it in "Base class" list in "Promoted Widget" !!!
-
By the way I asked this question because I couldn't fix this issue in [url=https://developer.qt.nokia.com/forums/viewthread/7285/]this[/url] post
-
You'll have to use QWidget as a base class.
-
[quote]You’ll have to use QWidget as a base class.
[/quote]
It's not working! -
What's not working?
What error messages do you get? -
[quote]What error messages do you get?[/quote]
Nothing just I noticed that promoting process didn't done because I didn't get "Demote to <QtClass>" just like any other class.PS
Could you please test Promote process on [url=http://www.mediafire.com/file/9rebbbdumq982df/MDITest.zip]this[/url] project (it's tiny project) -
You can put a QFrame on your form instead of a QMdiArea, right click it and promote the QFrame to your mdiArea class.
The Qframe will act as a placeholder in Qt Designer, but when compiling it will be considered a midArea. -
i tested it myself and it works.
I had to do some minor changes in your code :
in MainWindow constructor :@// ui->frame = new MdiArea(QImage(":/img/gnome-graphics.png"), Qt::red);
ui->frame->addSubWindow(new MdiArea(QImage(":/img/gnome-graphics.png"), Qt::red));@in MdiArea class I added a default constructor which is needed by moc
@ MdiArea(QWidget * parent = 0)
{
i = QImage(":/img/gnome-graphics.png");
b = Qt::yellow;
}@Of course it will not be exactly what you want. My purpose was to test the approach explained above with your class.
-
[quote]i tested it myself and it works.[/quote]
I tried it for QFrame but it didn't work for me so could you please upload your modified project?Designer didn't accept to Promote QMdiArea for QFrame base class!!!
-
Those lines I mentioned are the only ones that I changed.
bq. Designer didn’t accept to Promote QMdiArea for QFrame base class!!!
I think your problem is here : I see that you tried to use QMdiArea, but as you can see in my example I use your MdiArea class instead.
For completeness : here are the choices I made in the "promoted Widgets" dialogbox. You won't see that in the project if I send it to you.
Base Class name : QFrame
Promoted class name : MdiArea
header file : mdiarea.hclick button "Add" and then click button "Promote"
That's it.
EDIT : if you still need the altered project. just let me know.
-
[quote]I think your problem is here : I see that you tried to use QMdiArea, but as you can see in my example I use your MdiArea class instead.
.
.
.
Base Class name : QFrame
Promoted class name : MdiArea
header file : mdiarea.h
click button “Add” and then click button “Promote”
[/quote]
No no, I did the same steps but the last one doesn't exist (while it works for other classes) -
bq. I did the same steps but the last one doesn’t exist
What do you mean exactly? is the Add button grayed out or the Promote button? Do you get an error message?
-
[quote]is the Add button grayed out or the Promote button?[/quote]
Promote button grayed out.See this screenshot please:
http://img705.imageshack.us/img705/3389/screenshot1oy.jpgPS
Do you think it's betten to send you screencast? -
bq. Promote button grayed out.
See this screenshot please:that's normal
You have to fill in the dialogbox first than the Add button gets available and after that the promote button can be used.
I explained this already, did you do it like that?bq. For completeness : here are the choices I made in the “promoted Widgets” dialogbox. You won’t see that in the project if I send it to you.
Base Class name : QFrame
Promoted class name : MdiArea
header file : mdiarea.h
click button “Add” and then click button “Promote”EDIT : missed it that you already created it. just select what you alread made and then the button should be available
-
[quote]just select what you alread made and then the button should be available[/quote]
I selected it. It still unavailable!!!!I'll upload a sceencast to see what's going on
-
cold you please see the following screencast
http://eng-svu.al-yarmook.com/MdiArea/ -
You used a QMdiArea as the place holder. It should be a QFrame in Qt Designer because you subclass QFrame.
!http://dl.dropbox.com/u/33544011/MdiArea.PNG(Have a look at this screenshot)! -
[quote]You used a QMdiArea as the place holder. It should be a QFrame in Qt Designer because you subclass QFrame.[/quote]
Does it mean I've to morph QMdiArea to QFrame?! If yes this is huge disaster to me because I created many widgets in subwindows by Designer so I've to use really QMdiArea instead of QFrame.Do you've any solution?
-
bq. Does it mean I’ve to morph QMdiArea to QFrame?! If yes this is huge disaster to me because I created many widgets in subwindows by Designer so I’ve to use really QMdiArea instead of QFrame.
Yes you have to use a QFrame and add the subwindows in code. That's not so much work. If you have made a class with ui, you can use Designer to make the visual appearance of the widgets you want to use in the MdiArea..
I tested it with your own MdiArea, but it can be anything...
@// ui->frame = new MdiArea(QImage(":/img/gnome-graphics.png"), Qt::red);
ui->frame->addSubWindow(new MdiArea(QImage(":/img/gnome-graphics.png"), Qt::red));
ui->frame->addSubWindow(new MdiArea(QImage(":/img/gnome-graphics.png"), Qt::green));@ -
Thanks a lot guys I fixed this issue by:
@QList<QMdiSubWindow *> windows = ui->mdiArea->subWindowList();
qDebug("%d", windows.count());
for (int var = 0; var < windows.count(); ++var) {
QMdiSubWindow *wind = windows[var];
ui->frame->addSubWindow(wind->widget());
}
ui->mdiArea->setVisible(0);@