I'm using progress bar in my app. when i navigating first widget to second widget and in-between i'm using progress bar in another widget.
//code:
progressform *pgm = new progressform(); // calling progress bar widget
pgm->adjustSize();
pgm->show();
for(int i=24;i<=100;i++) //initial setvalue is 24
{
pgm->ui->progressBar->setValue(i);
}
detailWidget *dwt = new detailWidget(); // calling detail widget
dwt->show();
Before going to detailwidget i called progressform(widget) and after that the progressbar setvalue reach 100 it moves to detailwidget. the problem is i cant resize the progress widget in to center of the screen like popup screen and I want to sleep time because i want to see the progress value increased one by one?
Thanks in advance
I can recommend using QProgressDialog instead which pops up centered automatically.
You'll have to center your progress bar manually. Popup screens do so automatically, but progress bars normally are used as part of a dialog. Therefore they are positioned by the dialog layout.
As for the sleeping, that's probably a design error. If your task is so fast you'd need a sleep just to see the progress bar, you shouldn't have a progress bar in the first place.
Related
I want to show tool tip on the QGLWidget but i must the call; QToolTip::showText(pos, "Message", qglwidgetPtr, rect(), 5000);
in another class.
So, tooltip disappears after releasing the mouse button. If I don't release it, the tooltip disappears after that 5000 msecs. I do not understand the disappear problem. I think it could be trigger disappear QGL widget paint event but i'm not sure.
First of all, let's understand what is the reasion of the problem. Tooltips should hide when user move the mouse cursor not above them. So, when you release the mouse button somewhere else, your OS catches a mouse event not above the tooltip (not near starting point of that tooltip), so it hides the tooltip.
So, my solution is following: create QTimer and show your tooltip few times per second as long as you need (5 seconds). You can do it, because in the documentation it is said that
If the text is the same as the currently shown tooltip, the tip will not move
(i.e. it is ok to call showText many times with the same text)
To create the timer you can use this code:
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(100); // ten times per second
And inside the body of the update() function you can compare current time and the time of first showing of this tooltip, and to show your tooltip if it is still necessary (i.e. if it is shown less than 5 seconds).
howLongShown = curTime - startTime; // startTime here is the moment of first showing of the tooltip
if (howLongShown < 5000)
QToolTip::showText(pos, "Message", qglwidgetPtr, rect(), 5000 - howLongShown);
I have a MFC dialog based application with a picture control and some buttons on the dialog. I register the button click using:
ON_BN_CLICKED(IDC_BUTTON_START, OnBnClickedButtonStart);
If I update the picture in OnPaint() using StretchBlt() at about 10 to 30 pictures per second triggered from calling Invalidate() inside a worker thread, the button click stops being responsive.
Is there way to get around this? Thank you.
I have a member of CWnd class name mywindow
and i want to add to it a scroll-bar.
how i can do it?
i try already to do:
mywindow.EnableScrollBarCtrl(SB_BOTH,TRUE);
it display both Horizontal and Vertical scroll-bars,
but i cannot push the buttons or move the scroll-bars.
i try also after the first command:
mywindow.EnableScrollBar(SB_BOTH,ESB_ENABLE_BOTH);
and it change nothing.
can someone could show me a simple example how to add scroll-bar to this member?
thanks a lot,
Tal
Enabling the scroll bars isn't enough. You have to react to the window messages WM_HSCROLLand WM_VSCROLL. Using the GetScrollInfo method you get the position (value) of the scroll bars and then you draw your window content according to this position.
Look up some scroll bar tutorials such as http://www.codeproject.com/KB/dialog/scrolling_support.aspx . In essence, dwo's comment above is what you need to do - handle those messages and set the virtual client area size.
There must be some 'overflow' before scroll bars became active.
Write some 'sufficiently long' data in your view and the scrollbars will become active (at least, that was my experience time ago).
Usually scroll bars get handled 'automatically' from MFC components like (for instance) text editor or form view. I.e. will became visible when needed also without explicit call EnableScrollBarCtrl ...
I need an event for detecting if an user has moved the scrollbar position to another one.
In other words, if the user does scroll up/down, would it be possible to catch a signal so I can know the scroll has been changed its position?
I think it's not important, but the scrollbar I refer to is inside a QGraphicsView.
Regards.
Edit:
QGraphicsView is for displaying items in the screen, and if those items are too big it shows the scrollbars I refer to. What I need is to know when the user changes the position of those scrollbars.
Sliders have a sliderMoved(int value) signal, where value is the new position of slider.
If you need to get notified when the scroll bar position is changed, you need to subclass the QGraphicsView and reimplement the QWidget::mouseMoveEvent(QMouseEvent*). For this you also need to enable mouse tracking. Here is Qt 4.7 QGraphicsView reference.
Let's say that I have an application frame, and I want to show a popup QCalendarWidget over on the right side of the frame. Normally, QT will clip the edges of the QCalendarWidget, cutting it in half and not displaying the rest, as it would be over the right side border.
Is there a way to work around this limitation without resorting to implementing a QDialog?
I want the widget to be visible outside the bounds of it's container.
If you'd show your Calendar, let's say, after a button click, as QDateTimeEditor does, it's contents will not be clipped, cause it do not belong to frame. It will be just a widget, that shows in a dialog manner. And maybe you should even place it in QDialog, that is modal and provides some convenience methods, rather then simple QWidget.
Btw, why don't you want to use QDatetimeEditor?