How to add QStatusBar to QDialog in QDesigner (the QDialog allready styled )
-
Hello all (sorry if i post to much )
i have QDialog that is heavily designed with QDesigner , i saw on the web that i could add QStatusBar with code like this :
@ #include <QDialog>
#include <QStatusBar>
#include <QLayout>
#include <QApplication>
#include <QTextEdit>
#include <QStatusTipEvent>class Dialog : public QDialog { public: Dialog() : QDialog(){ QLayout *l = new QVBoxLayout(this); QTextEdit *te = new QTextEdit; te->setStatusTip("XXX"); l->addWidget(te); bar = new QStatusBar; l->addWidget(bar); l->setMargin(0); l->setSpacing(0); } private: QStatusBar *bar; protected: bool event(QEvent *e){ if(e->type()==QEvent::StatusTip){ QStatusTipEvent *ev = (QStatusTipEvent*)e; bar->showMessage(ev->tip()); return true; } return QDialog::event(e); } }; int main(int argc, char **argv){ QApplication app(argc, argv); Dialog dlg; return dlg.exec(); }@
its not even working in my case .. maybe the QDialog is already have few layets that holds widget .
my question is can i some how use palceholder in the QDesigner or somehow promote widget that place hold the QStatusbar class
i don't know ...
what can i do in such case? can i implement new QStatusbar?
Thanks -
Thou shall not reimplement virtual methods in a header file.
-
You can create a statusbar plugin and use it in Designer directly that way, see the "documentation":http://doc.qt.nokia.com/4.7/designer-creating-custom-widgets.html:
-
[quote author="Volker" date="1306412536"]Thou shall not reimplement virtual methods in a header file.[/quote]
Really? Any explanation for that one? I do that here and there, and it works just fine for what I do...
-
Volker's idea it's good because some compilers don't create v-table if virtual functions are implemented in header files.
-
what i did is in designer i added widget as place holder , and then in my application i removed it and replaced it with my statusbar , working file .
-
[quote author="cincirin" date="1306498651"]Volker's idea it's good because some compilers don't create v-table if virtual functions are implemented in header files.[/quote]
OK, thanks for that explanation. -
umen242, you can use Promote to... context menu item in designer
-
[quote author="cincirin" date="1306498651"]Volker's idea it's good because some compilers don't create v-table if virtual functions are implemented in header files.[/quote]
That's especially the case, when you do not have other method implementations in a .cpp file. If I remember correctly, that's one of the the reasons why it's recommended to implement a virtual destructor always in a .cpp, even if it's empty, as it forces the creation of a vtable.
-
thanks for the answers ,what i did is in the designer i used widget as place holder , then in the application i removed it and replaced with my status bar