Results 1 to 9 of 9

Thread: QWidget::update does not work!

  1. #1
    Join Date
    Mar 2011
    Posts
    7
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QWidget::update does not work!

    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?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QWidget::update does not work!

    Any suggestions?
    Post the code.

  3. #3
    Join Date
    Mar 2011
    Posts
    7
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QWidget::update does not work!

    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;


    }

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QWidget::update does not work!

    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 ?

  5. #5
    Join Date
    Mar 2011
    Posts
    7
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QWidget::update does not work!

    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?

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QWidget::update does not work!

    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.

  7. #7
    Join Date
    Mar 2011
    Posts
    7
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QWidget::update does not work!

    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 by
    Qt Code:
    1. QSlider *ang = new QSlider(0, 180, 1, 0, Qt::Horizontal, sliderBox, "angle");
    To copy to clipboard, switch view to plain text mode 
    it 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(). ?

    Thank you

  8. #8
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QWidget::update does not work!

    QHboxLayout is a subclass of QLayout, so you can use any method that QLayout has, for example QLayout::addWidget

  9. #9
    Join Date
    Mar 2011
    Posts
    7
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QWidget::update does not work!

    Thanks a lot for your help.
    It works now. I just added
    Qt Code:
    1. ang->show()
    To copy to clipboard, switch view to plain text mode 
    because the isVisible() used to return false

Similar Threads

  1. Replies: 1
    Last Post: 16th September 2010, 15:57
  2. Replies: 0
    Last Post: 29th April 2010, 05:44
  3. Unable to update QTableWidget which is on Different QWidget from MainWindow
    By sagar.mangalwedhekar in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2010, 07:07
  4. update() in QWidget
    By salmanmanekia in forum Qt Programming
    Replies: 5
    Last Post: 28th July 2008, 08:03
  5. QWidget::update() qeustion
    By tanki95 in forum Qt Programming
    Replies: 7
    Last Post: 14th March 2008, 02:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.