I want an 'expandable' window/widget.When clicking a button on the current window, another widget will shows up, which is attached to the current window, and it can be 'fold' back if clicking the button again.
It is not a pop-up window which is free to move with respect to the main window. I want it to be attached to the main window. Anyone has any idea? Thanks a lot.
I tried making a large window consisting of two box, with one being tackled to show or hide, but the window size does not change. If you resize the window, then the position does not look right.
Have you had a look at http://seriss.com/people/erco/fltk/ and the test programs that come with the fltk distribution?
Basically you need to set one resizable widget for the window/dialog. Make this the group that you are showing/hiding when you press the button.
If you have an FLTK distribution, have a look at the program test/resize.cxx as an example of how to do resizing based on button clicks.
I'm not sure I understand what your exact problem is...
Perhaps you need a widget that's not always shown on your main Fl_Window.
Then pressing another button makes it visible and attached somewhere in
the window, according to the window's size...
And when you resize the window, it changes its position, so it is always located,
let's say, at the bottom right of it. If I have understood your problem correctly,
then make a class, myWindow or whatever, a subclass of Fl_Window.
And override the resize function, which is called when the window is being resized.
class myWindow:public Fl_Window{
Fl_Button *mySpecialWidget; //the movable widget (not allways a button ofc)
public:
myWindow(int x, int y, int w, int h, const char *L=NULL):
Fl_Window(x,y,w,h,L){
mySpecialWidget = new Fl_Button(.....); //initialize subwidget here
add(mySpecialWidget); //add it as a subwidget of myWindow
//may also include all the other needed widgets here...
}
void resize(int x, int y, int w, int h){
//override this Fl_Window function, with
//any extra functionality that you need
//example, check window size-> set relevant position for mySpecialWidget
}
}
Related
I have a QTreeView widget placed inside a QDockWidget:
I want to set the properties of the QTreeView, that it automatically fills the whole available client drawing area (similar as WinForms DockFill property).
How can this be achieved with the QT-Designer?
Note: I've been playing around with the QTreeViews sizePolicy properties. If these are set to Expanding (as is the default) the accepted answer works out out of the box.
In Qt Designer, right-click the dock-widget, and then select Lay out -> Lay Out Vertically from the menu. Or you can just click on the dock-widget to select it, and then use the equivalent layout toolbar buttons.
If you want to maximise the space taken up by the tree-view, select the first child widget of the dock widget (it will probably be shown as dockWidgetContents in the Object Inspector pane). Then scroll down to the bottom of the Property Editor, and reset all the margins to zero.
I am trying to make a MFC SDI application in VC++ to draw different shapes on click of the respective button. We have written our code inside the OnDraw() function. But Ondraw gets automatically called on running the application. We want it to be called only on the onclick of respective button. How do we proceed..?
When a shape button is clicked set a member variable that remembers what you want to draw.
Call Invalidate. This will cause OnDraw to be called by the framework.
In OnDraw check the member variable and draw the shape.
You must permit OnDraw to draw every time it is called by the framework. That is how the window image is restored after being uncovered, unminimized, resized, etc.
You cant prevent that OnDraw is only called when you press a button.
OnDraw in a view is called when WM_PAINT arrives and asks the window to repaint itself. Not executing OnDraw would cause nothing to be drawn at all.
OnDraw is also called when your application is minimized and maximized again, or when the size of the window changes.
Also I can not think about a scenario, where I want drawing only when a button is pressed. You need to be more precise. here.
OnDraw, as xMRi said, is called by the framework ... but if you want to draw something only when you click on a button, why don't you create a member variable, setup when you click the button, and get count when OnDraw is executed ?
void CYourAppView::OnDraw(CDC* pDC)
{
// MFC code
if(m_bButtonWasClicked)
{
// draw what ever you want
}
}
I have:
self.setScene(QtGui.QGraphicsScene(self))
self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse)
self.setDragMode(QtGui.QGraphicsView.ScrollHandDrag)
where self is QGraphicsView. I am opening my svg in QGraphicsWebView() because of it's interactivity like this:
s = self.scene()
s.clear()
self.resetTransform()
self.webview = QGraphicsWebView()
self.webview.load(QtCore.QUrl(path_to_my_svg))
self.webview.setFlags(QtGui.QGraphicsItem.ItemClipsToShape)
self.webview.setCacheMode(QtGui.QGraphicsItem.NoCache)
self.webview.setZValue(0)
s.addItem(self.webview)
Zooming works fine, but when I click over webview item in order to drag it, nothing happens except cursor is changed to text cursor. I can drag svg only when I open it like self.svgItem = QtSvg.QGraphicsSvgItem(path_to_my_svg) but in that case it's rendered as static image so I lose interactivity in svg(mouseover, mouseout in svg elements)...
EDIT based on xndrme's comment:
As he suggested SHIFT+mouse left click works well, but it drags the whole SVG which is inside self.webview. Apparently I've thought that when I zoom with mouse scroll svg gets zoomed, but actually self.webview is the one that gets zoomed and scroll bars appears. So, what I've actually need to know is how to drag the whole self.webview within its scroll bar boundaries (with left mouse click)
In my application, I have two toggle buttons which can change the layout of a window. They will remove or add buttons to it effectively changing the total requested size. Since the Resizeable property of that window is set to false, normally the window would automatically resize to fit it's contents, whether they are larger than before or smaller.
However if I change the layout while the window is hidden, after I make it visible the dimensions of the window won't have changed to fit the layout. It will auto resize after I move it around though.
//Code example
Window.Hide();
ChangeLayout(Window);
Window.Show();
I assume GTK skips to check for size changes while a container is invisible. Is there a way to force it to recalculate it's size?
Thank you.
P.S: It seems that only happens in Windows. Perhaps this is OS related?
I don't have a windows machine to test it on, but try this as a workaround:
Window.Hide();
ChangeLayout(Window);
Window.Unrealize();
Window.Show();
You might also try setting the window resizable before changing the layout and then setting it unresizable:
Window.Hide();
Window.Resizable = true;
ChangeLayout(Window);
Window.Resizable = false;
Window.Show();
I have a UIScrollView (managed by a view controller) which I am using both full screen and as a subview. The full screen version works fine - the subview does not.
The subview is positioned so that it takes up about the bottom half of the screen, with a small - 20 pixels or so - margin at the bottom.
Initially it displays in the correct position but overwrites the bottom margin - even though the scrollview's frame is set to leave the margin.
When I scroll the view up by dragging it, the whole view moves upwards and obscures the top of the window. The frame stops moving when it hits the navigation bar at the top and starts scrolling like a normal scrollview. If I scroll it enough it eventually reveals the margin at the bottom of the screen.
I am at a loss to know what to do - I've tried every spring combination I can think of. I'm now looking at subview clipping.
Images below. The first shows the scrollview on initial page load, positioned correctly aside from lower margin overwrite. The scroll view has a white background.
The second image shows it scrolled up toward the top:
The third image shows it scrolled all the way up to the top - note that the lower margin has become visible.
I'm not 100% sure on this one, but worthy the shot: my guess is you're likely not setting the Bounds property correctly on your table.
To solve this issue, the easiest way would be to set myscrollview.clipsToBounds = true.
Something is definitely wrong here. I think what happens is that you are adding the same instance of scrollview as a subview on itself. So basically what you are left with, is one instance alone. Anything you add to the "subview", is basically added on the superview, since it is the same object.
For example, this is what I think you are doing in the view controller:
//...
private UIScrollView myScrollView;
public override void ViewDidLoad()
{
this.myScrollView = new UIScrollView();
this.View = this.myScrollView;
this.View.AddSubview(this.mySrcollView); // same instance
this.myScrollView.AddSubview(aUIButton); // "aUIButton" will be added in View also, since it is the same object
}
If this is the case, it is wrong. I suggest not changing the controller's view at all. If you want to have a controller that has a fullscreen UIScrollView, just create it and add it as a subview, making sure the AutoSizesSubviews property to true.
That's my understanding at least.