Results 1 to 4 of 4

Thread: QStackedLayout dialog flicker

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    14

    Default QStackedLayout dialog flicker

    Hi,

    I was trying out example about Stacked Layouts from the book "C++ GUI Programming with Qt 4, Second Edition" its Chapter 6.

    Qt Code:
    1. PreferenceDialog::PreferenceDialog(QWidget *parent)
    2. : QDialog(parent)
    3. {
    4. ...
    5. listWidget = new QListWidget;
    6. listWidget->addItem(tr("Appearance"));
    7. listWidget->addItem(tr("Web Browser"));
    8. listWidget->addItem(tr("Mail & News"));
    9. listWidget->addItem(tr("Advanced"));
    10.  
    11. stackedLayout = new QStackedLayout;
    12. stackedLayout->addWidget(appearancePage);
    13. stackedLayout->addWidget(webBrowserPage);
    14. stackedLayout->addWidget(mailAndNewsPage);
    15. stackedLayout->addWidget(advancedPage);
    16. connect(listWidget, SIGNAL(currentRowChanged(int)),
    17. stackedLayout, SLOT(setCurrentIndex(int)));
    18. ...
    19. listWidget->setCurrentRow(0);
    20. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void MainWindow::configurationOptions()
    2. {
    3. PreferenceDialog *optionsDlg = new PreferenceDialog();
    4. optionsDlg->exec();
    5. delete optionsDlg;
    6. }
    To copy to clipboard, switch view to plain text mode 


    The problem is that when I start the example I see ugly flicker on a dialog, hence my question how can this be eliminated ? I have try to use resize to make the dialog bigger by default but that didn't help.

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

    Default Re: QStackedLayout dialog flicker

    You'll have to define "ugly flicker" and when exactly you see it. Reizing the dialog, switching pages, as you type, one one particular page etc. Does the Config Dialog Example display similar flickering?

  3. The following user says thank you to ChrisW67 for this useful post:

    ArkKup (11th December 2012)

  4. #3
    Join Date
    Jan 2011
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    14

    Default Re: QStackedLayout dialog flicker

    sorry for not being too specific by "ugly flicker" I meant that the dialog windows shows and I can see that its being resize quickly.
    Config Dialog Example works just fine.

  5. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: QStackedLayout dialog flicker

    as an aside, please don't write code like this
    Qt Code:
    1. void MainWindow::configurationOptions()
    2. {
    3. PreferenceDialog *optionsDlg = new PreferenceDialog();
    4. optionsDlg->exec();
    5. delete optionsDlg;
    6. }
    To copy to clipboard, switch view to plain text mode 
    We are not java programmers... Instead write
    Qt Code:
    1. void MainWindow::configurationOptions()
    2. {
    3. PreferenceDialog optionsDlg
    4. optionsDlg.exec();
    5. }
    To copy to clipboard, switch view to plain text mode 
    Shorter, quicker, easier to read, less prone to errors.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. QStackedLayout / QStackedWidget
    By morraine in forum Newbie
    Replies: 15
    Last Post: 12th July 2013, 09:16
  2. QStackedLayout and setContentsMargins()
    By Carlsberg in forum Qt Programming
    Replies: 1
    Last Post: 15th November 2012, 14:47
  3. Scrollbars for QStackedLayout
    By JohannesMunk in forum Newbie
    Replies: 0
    Last Post: 6th December 2009, 16:50
  4. Adding layouts to QStackedLayout
    By Scraggy in forum Qt Programming
    Replies: 3
    Last Post: 10th November 2008, 19:01
  5. QStackedLayout vs. QStackedWidget
    By bruccutler in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2007, 23:43

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
  •  
Qt is a trademark of The Qt Company.