Hello,
I am trying to update the widget after inserting new qsliders, but it does not update the widget and the slideer does not apear!! I am using qt 3 btw. Any suggestions?
Hello,
I am trying to update the widget after inserting new qsliders, but it does not update the widget and the slideer does not apear!! I am using qt 3 btw. Any suggestions?
Post the code.Any suggestions?
Here is the part of the code where I am trying to update:
void winfold(){
setUpdatesEnabled( FALSE );
QSlider *ang = new QSlider(0, 180, 1, 0, Qt::Horizontal, sliderBox, "angle");
emit(whichindex(sliders.size()));
connect(this, SIGNAL(whichindex(int)), glwidget, SLOT(set_index(int)));
connect(ang, SIGNAL(valueChanged(int)),this, SLOT(set_ang(int)));
sliders.push_back(ang);
glwidget->fold_sync();
// QWidget::update();
cout<<isVisible()<<endl;
setUpdatesEnabled( TRUE );
// repaint();
update();
cout<<"I UPDATED THE WINDOW!! "<<sliders.size()<<endl;
}
Ok, but in order to display the slider, you'll need to add it to widget's layout. Only thing I see is that you push the slider into some list, are the elements added to layout later ?
I have done this in my Window constructor:
QHBoxLayout* mainLayout = new QHBoxLayout( this, 20, 20, "mainLayout");
mainLayout->addWidget( sliderBox );
I have already done this in my Window constructor:
QHBoxLayout* mainLayout = new QHBoxLayout( this, 20, 20, "mainLayout");
mainLayout->addWidget( sliderBox );
Isn't this enough?
Clearly not. Your constructor adds "sliderBox" to a layout that we can only assume you apply as Window's layout.
You then create a new QSlider that I assume you wish to become part of the "sliderBox" widget's display. You need to add the new QSlider widget you create to the existing layout of "sliderBox" (not the main window). We have no details of "sliderBox".
What class does winfold() belong to?
Please use [code] and [/code] tags around your code.
Well, I have a window class and the winfold() is a slot in my window.h, the point is that this sliders are shown up if I do the same thing in the constructor of my Window class, and I thought that byit would add it to the sliderBox as well, as it is doing so when I do the same thing in constructor... and I could not find any method in QHBox for adding an object to it. That's why I was led to believe that problem is from update(). ?Qt Code:
To copy to clipboard, switch view to plain text mode
Thank you
QHboxLayout is a subclass of QLayout, so you can use any method that QLayout has, for example QLayout::addWidget
Thanks a lot for your help.
It works now. I just added because the isVisible() used to return false
Bookmarks