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. QToolBar and other QWidgets
Forum Updated to NodeBB v4.3 + New Features

QToolBar and other QWidgets

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 866 Views 2 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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    I'm trying to do something simple but I don't understand how to do.
    In a QMainWindow I have two QToolBar: one places in the top side and the other in the left side. Both fill the whole width and height of the window.

    Instead I need to place some other QWidget at the beginning or at the end of the tool bars. Say, in the left-top corner I would place a QImage to show the logo and hence the tool bars should be placed at the right and bottom side of this widget.

    Even simpler, I cannot place the tool bar in a QLayout (the Designer doesn't allow me to drag and drop them).
    Any idea?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      you mean insert QImage outside the toolbar(s) but in same area where it lives ?

      While you can insert a toolbar in a layout from code, it would disable Mainwindows normal features
      of being able to float them and drag toolbars around.

      M 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        you mean insert QImage outside the toolbar(s) but in same area where it lives ?

        While you can insert a toolbar in a layout from code, it would disable Mainwindows normal features
        of being able to float them and drag toolbars around.

        M Offline
        M Offline
        Mark81
        wrote on last edited by
        #3

        @mrjj said in QToolBar and other QWidgets:

        you mean insert QImage outside the toolbar(s) but in same area where it lives ?

        Exactly. Another example: in my vertical tool bar I only have three big buttons. I would use the space below them to put other stuff, outside the tool bar but in the same "vertical" area, like if they are using a QVBoxLayout.

        While you can insert a toolbar in a layout from code, it would disable Mainwindows normal features
        of being able to float them and drag toolbars around.

        I'm not interested in these features. Because I've already customized my toolbars from the Designer I would like to avoid to re-write all the code in the cpp file.

        Could I just "move" them reassigning the parent to a new QLayout?

        mrjjM 1 Reply Last reply
        0
        • M Mark81

          @mrjj said in QToolBar and other QWidgets:

          you mean insert QImage outside the toolbar(s) but in same area where it lives ?

          Exactly. Another example: in my vertical tool bar I only have three big buttons. I would use the space below them to put other stuff, outside the tool bar but in the same "vertical" area, like if they are using a QVBoxLayout.

          While you can insert a toolbar in a layout from code, it would disable Mainwindows normal features
          of being able to float them and drag toolbars around.

          I'm not interested in these features. Because I've already customized my toolbars from the Designer I would like to avoid to re-write all the code in the cpp file.

          Could I just "move" them reassigning the parent to a new QLayout?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @Mark81
          Well the QToolBar is a normal widget so its possible to use it as such. Like say in a Dialog.
          So your idea should not be impossible.

          • Because I've already customized my toolbars from the Designer
            well we could just take the code from setupUI so it would not have to be rewritten. :)

          • Could I just "move" them reassigning the parent to a new QLayout?
            Well im not really sure what the QToolbar area really is.
            If its a layout of sorts, then reassigning parent might not work as we expect as
            for layout TakeAt seems the way to transfer ownership.
            But please try it :) It it doesnt work, we should find out via source code or
            via findChildren(); and see what we are dealing with.

          Update. had a quick looks and it seems to live in a QToolBarLayout
          which seems to be a private class. tried to use TakeAt but gave me null ptr.

          1 Reply Last reply
          3
          • M Offline
            M Offline
            Mark81
            wrote on last edited by
            #5

            Following your hints I did that entirely by code.

            1 Reply Last reply
            1

            • Login

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