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. MenuBar size

MenuBar size

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 12.4k Views
  • 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.
  • H Offline
    H Offline
    hcts
    wrote on 30 May 2013, 10:06 last edited by
    #1

    Hi all,

    I'm very new in Qt and I do not work with Qt, I would like only to learn for fun, but I have almost no time to research about my doubts (I have only some minutes per day) and my test program is progressing very slow. In order to increase developing speed I will ask some questions here. First, I would like to know how can I adjust width of a menu bar according the form size that this menu bar is inside. Does anybody could help me?

    Thanks in advance,
    Hcts

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hareen Laks
      wrote on 30 May 2013, 11:33 last edited by
      #2

      I'm also new one to Qt.

      According to my knowledge I think by default menubar width is set to the form width. isn't it?

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qxoz
        wrote on 30 May 2013, 12:20 last edited by
        #3

        Hi hcts!
        Show us your code.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jeroentjehome
          wrote on 30 May 2013, 14:46 last edited by
          #4

          The tool bar is adjustable by the minimumSize option etc. The icons, or text in the toolbar determine the size of the toolbar.
          Greetz

          Greetz, Jeroen

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jeroentjehome
            wrote on 30 May 2013, 14:49 last edited by
            #5

            oh, sorry,
            My mistake, you discussed the menuBar!!
            The menuBar size is changeable with the font point size for example. The menuBar is resized with the contents just like the toolbar. Icons or text size determine the size of it.
            Greetz

            Greetz, Jeroen

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hcts
              wrote on 30 May 2013, 14:52 last edited by
              #6

              Hi,

              Thanks for all answers.

              I'm creating the QMenuBar at runtime, like this:

              QMenuBar MenuObject = new QMenuBar(this);
              HeaderArea->addWidget(MenuObject);

              where HeaderArea is QHLayoutBox.

              Regards,
              Hcts

              1 Reply Last reply
              0
              • J Offline
                J Offline
                Jeroentjehome
                wrote on 30 May 2013, 14:58 last edited by
                #7

                Oke, the size of the QMenuBar can be set runtime, no problem, but if the answers where enough, mark this post as [SOLVED]

                Greetz, Jeroen

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  hcts
                  wrote on 30 May 2013, 15:00 last edited by
                  #8

                  Hi,

                  How can I do that a t runtime, could give me an example?

                  Regards,
                  Hcts

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hcts
                    wrote on 31 May 2013, 18:22 last edited by
                    #9

                    Hi all,

                    It seems that the QMenuBar width is by default according to parent widget size. My problem was that the QMenu inside the QMenuBar was in a different color in comparison of QMenuBar and QWidget. QMenu was gray and QWidget and QMenuBar were white. The result of this is that the QMenuBar finished at the middle of parent QWidget.

                    The code below shows the QMenuBar using all parent QWidget size as your own size, when the size of widget is changed by the user, QMenuBar size change too.

                    #include <QtGui/QApplication>
                    #include <QMenuBar>

                    int main(int argc, char *argv[])
                    {
                    QApplication app(argc, argv);
                    QWidget *x = new QWidget();
                    x->setGeometry(30,30,600,600);
                    QMenuBar * q = new QMenuBar(x);
                    q->addMenu("Test");
                    q->setStyleSheet("background-color: white");

                    x->show();
                    return app.exec();
                    

                    }

                    So, my problem is solved only changing the color of QMenu.

                    Thanks

                    1 Reply Last reply
                    0

                    7/9

                    30 May 2013, 14:58

                    • Login

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