Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to add QStatusBar to QDialog in QDesigner (the QDialog allready styled )
Forum Updated to NodeBB v4.3 + New Features

How to add QStatusBar to QDialog in QDesigner (the QDialog allready styled )

Scheduled Pinned Locked Moved General and Desktop
10 Posts 6 Posters 11.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    umen242
    wrote on last edited by
    #1

    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&#40;&#41;;
    }@
    

    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

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Thou shall not reimplement virtual methods in a header file.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sigrid
        wrote on last edited by
        #3

        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:

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          [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...

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cincirin
            wrote on last edited by
            #5

            Volker's idea it's good because some compilers don't create v-table if virtual functions are implemented in header files.

            1 Reply Last reply
            0
            • U Offline
              U Offline
              umen242
              wrote on last edited by
              #6

              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 .

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                [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.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  alexander
                  wrote on last edited by
                  #8

                  umen242, you can use Promote to... context menu item in designer

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    [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.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • U Offline
                      U Offline
                      umen242
                      wrote on last edited by
                      #10

                      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

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved