Results 1 to 7 of 7

Thread: Update GUI

  1. #1
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Update GUI

    How to update a gui information correctly on. Weird things are happening on mac, when I update label or any of widget info. The best explanation is the screenshots attached.

    You can see a QDockWidget widget containing Qlabel for pixmap and QLabel for name and QTabWidget below.

    Some times when the text label is shorter you can see it behind the current text.

    In the example on screenshot you can see old QTabWidget behind the new one.

    How to fix it, tried update() things already ....

    That does not happening on linux.

    Thanksshot1.png

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Update GUI

    You have to use layouts.

  3. #3
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Update GUI

    what do you mean

    of course I do use layout (QVBoxLayout) for QDockWidget, that's how I add Qlabel = image, QLabel - name and QTabWidget.

    Could you write more details what you have on your mind please ? thanks

  4. #4
    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: Update GUI

    Layouts will not allow overlapping widgets, which is what seems to be happening with your progress bar. Can you show the code that constructs the dock widget layout?
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  5. #5
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Update GUI

    Qt Code:
    1. void MainView::createDock() {
    2. DEBUGME;
    3. lb_dockIcon = new QLabel;
    4. lb_dockIcon->setMaximumHeight(60);
    5. lb_dockIcon->setMinimumHeight(60);
    6.  
    7. lb_dockIcon->setAlignment(Qt::AlignCenter);
    8. lb_dockLabel = new QLabel;
    9. lb_dockLabel->setAlignment(Qt::AlignCenter);
    10.  
    11. _dockTabs = new QTabWidget;
    12.  
    13. _dockMainWidgetLayout = new QVBoxLayout;
    14.  
    15. _dockMainWidget = new QWidget;
    16. _dockMainWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    17. _dockMainWidget->setLayout(_dockMainWidgetLayout);
    18.  
    19. _dockWidget = new QDockWidget;
    20. _dockWidget->setContentsMargins(5,0,5,0);
    21. _dockWidget->setWidget(_dockMainWidget);
    22.  
    23. connect(_dockWidget, SIGNAL(visibilityChanged(bool)), this, SLOT(showDock(bool)));
    24.  
    25. _dockMainWidgetLayout->addWidget(lb_dockIcon, Qt::AlignCenter);
    26. _dockMainWidgetLayout->addWidget(lb_dockLabel);
    27. _dockMainWidgetLayout->addWidget(_dockTabs);
    28.  
    29. _dockMainWidgetLayout->setStretchFactor(lb_dockIcon,0);
    30. _dockMainWidgetLayout->setStretchFactor(lb_dockLabel,0);
    31. _dockMainWidgetLayout->setStretchFactor(_dockTabs,1);
    32.  
    33. }
    To copy to clipboard, switch view to plain text mode 

    and this is how I call it to print different data again

    Qt Code:
    1. void MainView::setDockData(IFile *file, bool) {
    2.  
    3. DEBUGME;
    4.  
    5. QPixmap icon(file->FilePixmap());
    6.  
    7. lb_dockIcon->setPixmap(icon);
    8. lb_dockIcon->updateGeometry();
    9.  
    10. QString name = file->FileName();
    11. FileWidget::wordWrap(name, 100, 25);
    12. lb_dockLabel->setText(name);
    13. lb_dockLabel->updateGeometry();
    14.  
    15. _dockTabs->clear();
    16. _dockTabs->show();
    17.  
    18. DockVersions *versions = new DockVersions(this, file);
    19.  
    20. DockAddIn *addIn = new DockAddIn(this, file);
    21. connect(addIn, SIGNAL(setDockTabTitle(int, QString)), this, SLOT(setDockTabTitle(int, QString)));
    22.  
    23. for(int i = 0;i < _dockTabs->count();i++) {
    24. _dockTabs->removeTab(i);
    25. }
    26.  
    27. _dockTabs->addTab(addIn, addIn->windowTitle());
    28. _dockTabs->addTab(versions, versions->windowTitle());
    29.  
    30. versions->display();
    31. addIn->display();
    32.  
    33.  
    34. }
    To copy to clipboard, switch view to plain text mode 

    thanks for looking

  6. #6
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Update GUI

    any ideas ??

  7. #7
    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: Update GUI

    You have not applied a layout to _dockWidget, only to to the dockMainWidget widget you place inside it.

Similar Threads

  1. Replies: 2
    Last Post: 29th September 2010, 17:44
  2. how to use update()?
    By zgulser in forum Qt Programming
    Replies: 0
    Last Post: 6th February 2009, 09:45
  3. Is Update() the right way?
    By td in forum Newbie
    Replies: 1
    Last Post: 5th December 2008, 14:54
  4. update()
    By JeanC in forum Qt Programming
    Replies: 4
    Last Post: 11th February 2008, 16:12
  5. Update a row
    By dragon in forum Newbie
    Replies: 9
    Last Post: 17th January 2006, 17:11

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.