Results 1 to 8 of 8

Thread: Problem updating a layout

  1. #1
    Join Date
    Aug 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Problem updating a layout

    Hi. I really hope that this is the right section to place my question..:P
    Well the problem is that i have a layout with a customized widget that renders a graph in openGL.. but each time i remove the widget from the layout to add a new one, with a different graph, the previous one stays there...( this makes the screen show sometimes the older graph and sometimes the new when i press the mouse in the widget area).
    I've already made a lot of updates and destroys on the previous one but the image really like where it is. The only way i can make the previous to stop rendering is to resize the whole application.. after that the previous stops showing..
    i don't have a clue of what to do... does anyone know how to solve this
    thanks in advance

  2. #2
    Join Date
    Aug 2010
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem updating a layout

    Maybe you should post some code. At least the code where you add and remove the widgets to the layout.
    Otherwise it's difficult to help here.

  3. #3
    Join Date
    Aug 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem updating a layout

    the initial code is this:

    self.imageLabel = QLabel()
    self.imageLabel.setMinimumSize(588,588)
    self.imageLabel.setAlignment(Qt.AlignCenter)
    self.imageLabel.setContextMenuPolicy(Qt.ActionsCon textMenu)
    self.imageLabel.setPixmap(QPixmap.fromImage(QImage ("images/img1.jpg")))
    self.imageLabel.setObjectName("imageLabel")

    self.centralLayout = QHBoxLayout()
    self.centralLayout.addWidget(self.imageLabel)

    after this to change the widget or replace by other this is what i do

    self.centralLayout.removeWidget(self.imageLabel)
    ...
    self.centralLayout.update()
    self.imageLabel = GLWidget(self.graph, self.leftGL, self.rightGL, self.bottomGL, self.topGL, self.colors, self)
    ...
    self.centralLayout.addWidget(self.imageLabel)

    thanks

  4. #4
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: Problem updating a layout

    So you removeWidget()...what do you do with the removed widget?

  5. #5
    Join Date
    Aug 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem updating a layout

    hmmm nothing... i just remove it and replace it by other... should i be doing something else?

  6. #6
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: Problem updating a layout

    Yes. You should delete it, using the delete() or deleteLater() function as appropriate.

  7. #7
    Join Date
    Aug 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem updating a layout

    delete? but the qwidget class doesn't have any delete... how do i do that?

  8. #8
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Problem updating a layout

    Actually it has the deleteLater(); member slot (inherited from QObject)

    LE: Back to original problem, have you tried to call repaint() (see also update()) after you change the central widget (or maybe another idea is to use the same widget and update it as necessary)
    Last edited by Zlatomir; 17th August 2010 at 00:46.

Similar Threads

  1. Problem with layout
    By franco.amato in forum Qt Programming
    Replies: 3
    Last Post: 18th December 2009, 19:32
  2. Problem with QListWidget Updating
    By flob in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2009, 17:05
  3. Replies: 1
    Last Post: 14th January 2009, 10:10
  4. Problem updating Line edit from a thread
    By raghvendramisra in forum Qt Programming
    Replies: 5
    Last Post: 3rd December 2007, 05:05
  5. Problem with QScrollArea updating from 4.0.1 to 4.1.0
    By SkripT in forum Qt Programming
    Replies: 8
    Last Post: 28th January 2006, 22:35

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.