Layout with invisible button steals click events from underlying button in Qt5 form (QtCreator) - c++

I have designed a form in QtCreator for Qt5 where I have a row of buttons without layout (Blueberry+, Peach, Lemon, Mango and Water in screenshot below) with a grid layout on top.
The grid layout has one button (Register Now), one label(HELLO JOHN) and two horizontal spacers inside:
In the code, the label and button in the layout are set to visible=false.
When I start the program and show the screen I only see the underlying row of buttons, but I can't click them. The layout seems to somehow steal the focus. I can verify this by moving the layout in the editor to see the boundary for where my clicks work following it.
Other than this there isn't much going on in the gui, so I am kind of stumped as to why a QGridLayout steals my clicks.
Any tips on how I can avoid this?

You should hide the QGridLayout itself and not the button and label.
You are done here if the button and label hides and shows togather.
if not. along with showing and hidding the grid. show and hide the label and button.
Does that seems to solve the problem?

Related

Is there a way to attach or anchor two QWidgets together?

I'm getting started with Qt and decided to build a full-screen text editor. I want to have a button (button with arrow in screenshot) attached to a QDockWidget which opens and closes it so the button is always visible to the right side of the screen and stay anchored to it when dock is visible or resized.
My current app is a simple fullscreen textEdit set to centeralwidget in Mainwindow.
I haven't found a way to do this yet with layouts or existing addAnchor() functions so any help or direction is appreciated.
You can achieve what you want by using a container for your text edit and the button. A QWidget instance can be used as an "invisible"*** container for other widgets.
So in Qt Designer you add a widget as a central widget of the main-window, inside this widget you add the text edit and the button, then you set a vertical layout for this container widget.
Don't forget to restrict the docking widget to only dock to the right side, you can do that with: dock->setAllowedAreas(Qt::DockWidgetArea::RightDockWidgetArea); //assuming dock is the pointer to your QDockWidget.
In case you want the dockWidget to be able to dock to any side and the button to follow, you can do that too, but it get a little bit more complicated. Basically you need to connect a slot to dockLocationChanged of your dockWidget and based on where it's docked you need to set-up a new layout for the container widget to be vertical or horizontal and the order of the textEdit and the button based on the side the dock happened.
LE:*** you will most likely need to set the margins you want, since both the widget and it's layout can have them and the actual content might have higher spacing than you want.

Make a Toolbar have a grid layout

I want to make a QToolBar have 3 columns of buttons when docked on the left side of the QMainWindow, but have 1 row when docked on the top of the main window. Is this possible?
I have a tried using a QToolBar with a custom layout, but the normal re-size behavior of the QToolBar doesn’t work (doesn’t hide widgets behind an expand button when its too small). The non-working expand button isn’t that big of a deal, but the bigger problem is that the custom layout prevents the main window from being smaller than the toolbar.
I was able to get my desired behavior by putting each row of Tool Buttons in a QHBoxLayout, putting that layout in a empty QWidget, and calling toolBar->addWidget( widget ) for each row. This gives me a grid toolbar when the toolbar is mounted on the left, and single horizontal bar when mounted on the top.

wxFormBuilder Toolbar Spacing

I am creating a layout using wxFormBuilder. I have a frame, wxBoxSizer (wxToolBar and wxListBook in it) and a wxMenuBar with a wxMenu in it, like so: http://i.imgur.com/Ibw6b.png
I then view the XRC Window and it seems ok: http://i.imgur.com/elEpq.png
Then, I add a tool to the toolbar, like so: http://i.imgur.com/qq0Od.png
The problem shows up when I then check the XRC Window and I see that there is a blank space between the menubar and the toolbar: http://i.imgur.com/jfqGK.png
How can I remove this gap? Thanks.
Normal, default frame toolbar shouldn't be added to the sizer managing the rest of the frame elements because it's already handled by wxFrame itself automatically, so if you just need a toolbar positioned in the standard location (as opposed to having a toolbar in the middle of a window or something like that) you just shouldn't do this. I'm still not sure where does the gap come from but I am pretty sure that it will disappear once you stop adding toolbar to the sizer.

ScrollArea and TabWidget resizing

I am having trouble with my app. I am not able to configure wigets to behave acording to my needs, I would appreciate help.
This is “sketch” of my real app
http://s13.postimage.org/ibzzdh3p3/tab_Widget.png
So the main widget of MainWindow is scrollArea.
ScrollArea has vertical layout and contains 3 items.
1. Is big button, which represents constant sized area in my real app
2. Is spacer
3. TabWidget, has layouts on both tabs.
Now my problem. I am putting dynamically content into those tabs and I expect that if tab content cannot fit the tab than it will expand TabWidget in the scroll area.
Now it is filling space right when it fits the place, nice spacing and so. But if I fill it with lets say more lines(height 600px), than I can see the lines dissapearing somewhere down the tab and if I expand whole window TabWidget gets more space and more of my hiden widgets gets revealed.
Any ideas how can I force the content of the tabwidget to expand it rather then hide under?

Float a control over a CView

I've got an app that uses several CView-derived classes (actually CScrollView) to display document data. For one particular view, I want to add a fly-out edit box to add notes. That is, you'd see a tab at the bottom of the window labeled "Page Notes", and clicking on that would bring up the edit box. Clicking the tab while the edit box is visible would reduce it back to just the tab.
I thought I could use a one-tab CTabCtrl holding an edit box and just position it so that only the tab is visible initially. Capture the tab click notification and move the entire control, with edit box, into view. Clicking the tab again would move it back down so only the tab is visible.
Hosting the CTabCtrl on the CView is fine, and I can get it positioned correctly. The problem is that if the view is scrolled, the tab control is scrolled along with it, whereas I need it to "float" over the view and not be affected by any scrolling. I can move it back into place after the scroll, but the flickering is unsightly.
Is there a straightforward way to accomplish the "floating" effect? I mainly want the tab embedded in the view for maintenance, since it's the only view class out of the several in use that needs the "Page Notes" feature.
Should I just buckle down and put the tab in the view's parent window instead? I know it won't be affected by scrolling there, but I like the idea of keeping the tab as part of the view if possible.
It sound like the tab is functioning like a button. You click the tab and a fly out edit box appears. You could use a modeless dialog.
Select the "Page Note" and the modeless dialog comes up to edit your notes allowing you to scroll your view under the dialog.