Results 1 to 20 of 21

Thread: flashing widgets

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default flashing widgets

    I need a bunch of controls that have fixed signal/slot bindings but can be placed into various dialogs depending on app modes. My solution is a widget that creates the control widgets as children of itself, but does not show them; it then connects to their signals using QMetaObject::connectSlotsByName(). Later I insert the controls into layouts in the variable dialogs.

    This works nicely except for one glitch: the control widgets "flash" briefly on screen as they are being created (on WinVista32, haven't tried others). The "flash" is not the whole widget, just a small window frame, -- whose style changes according to window flags passed to the widget c'tor. It happens whether the generating widget has a parent or not ( I create it parentless, otherwise a permanent small black rectangle shows in the parent's client area).

    Can anyone suggest a solution?

    Thanks, Tom

  2. #2
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: flashing widgets

    I suppose you do setVisible( false ) after you create the widget but before you add it to the control widget ?

    regards,
    Marc

  3. #3
    Join Date
    Aug 2008
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: flashing widgets

    Hi Marc

    Yes, I set the widgets invisible at creation and make them visible again before use. The flashing frames show up even if I set all the component widgets invisible too.

    -- Tom

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: flashing widgets

    Can we see some code?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Aug 2008
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: flashing widgets

    Here is the code that creates the flashing widgets
    Qt Code:
    1. PaniniParameters::PaniniParameters( QWidget *parent )
    2. : QWidget(0) // else get black hole in parent window
    3. {
    4. ppar = parent;
    5. genCtl( "upPitch", "pitch", -90, 90, 0,
    6. tr("pitch to world vertical, degrees"), QString());
    7. genCtl( "upRoll", "roll", -90, 90, 0,
    8. tr("roll to world vertical, degrees"), QString());
    9. genCtl( "camZoom", "zoom", 0, 100, 0,
    10. tr("lens zoom, % of range"),
    11. QString("photo"));
    12.  
    13. ... <10 more like those> ...
    14.  
    15. // connect signals to our slots
    16. QMetaObject::connectSlotsByName( this );
    17. }
    18.  
    19. void PaniniParameters::genCtl( const QString &name,
    20. const QString &label,
    21. double lo, double hi, double def,
    22. const QString &tip,
    23. const QString &chkLbl )
    24. {
    25. PaniniSlide * ps = new PaniniSlide( this, label, lo, hi, def, tip, chkLbl );
    26. ps->setObjectName( name );
    27. names_addrs.insert( name, ps );
    28. }
    To copy to clipboard, switch view to plain text mode 

    Here is the c'tor of PaniniSlide:

    Qt Code:
    1. PaniniSlide::PaniniSlide( QWidget * parent,
    2. const QString & lblv,
    3. float lo, float hi,
    4. float initv,
    5. const QString & tip,
    6. const QString & checkText,
    7. bool vert,
    8. int minlen, int maxlen
    9. )
    10. : QWidget( parent )
    11. {
    12. if(minlen < 1) minlen = 121;
    13. if(maxlen < minlen ) maxlen = 1001;
    14. // set checkbox text, hide it if none
    15. checkbox.setText( checkText );
    16. checkbox.setVisible( !checkText.isEmpty() );
    17. // set control data
    18. setLabel( lblv );
    19. setRange(lo, hi, initv );
    20.  
    21. // set control characteristics
    22. label.setAlignment(Qt::AlignHCenter);
    23. spinbox.setButtonSymbols(QAbstractSpinBox::NoButtons);
    24. slider.setTickInterval(10);
    25. slider.setTickPosition(QSlider::TicksLeft);
    26. // lay out the controls
    27. if( vert ) {
    28. slider.setOrientation ( Qt::Vertical );
    29. slider.setMinimumHeight( minlen );
    30. slider.setMaximumHeight( maxlen );
    31. slider.setSizePolicy( QSizePolicy::Fixed,
    32. QSizePolicy::MinimumExpanding );
    33. } else {
    34. slider.setOrientation ( Qt::Horizontal );
    35. slider.setMinimumWidth( minlen );
    36. slider.setMaximumWidth( maxlen );
    37. slider.setSizePolicy( QSizePolicy::MinimumExpanding,
    38. QSizePolicy::Fixed );
    39. }
    40. label.setFixedWidth( minW );
    41. spinbox.setFixedWidth( minW );
    42. QBoxLayout::Direction d = vert ? QBoxLayout::TopToBottom
    43. : QBoxLayout::RightToLeft;
    44. QBoxLayout * lay = new QBoxLayout( d, this );
    45. lay->addWidget(&slider);
    46. lay->addWidget(&label);
    47. lay->addWidget(&spinbox);
    48. lay->addWidget(&checkbox );
    49. setLayout( lay );
    50. // minimum widget size
    51. setMinimumSize( lay->minimumSize() );
    52. resize( minimumSize() );
    53. // add tool tips
    54. label.setToolTip( tip );
    55. spinbox.setToolTip( tip );
    56. slider.setToolTip(tr("\
    57. Drag sliders or type numbers.\n\
    58. Fine adjust: click number and\n\
    59. use up and down arrow keys.\n\
    60. Reset: left-dbl-click label.\n\
    61. Options: right-dbl-click label.\
    62. "));
    63.  
    64. //wire signals
    65. connect( &slider, SIGNAL(valueChanged(int)),
    66. this, SLOT(on_slider_valueChanged(int)));
    67. connect( &spinbox, SIGNAL(valueChanged(double)),
    68. this, SLOT(on_spinbox_valueChanged(double)));
    69. connect( &checkbox, SIGNAL(stateChanged(int)),
    70. this, SLOT(on_checkbox_stateChanged(int)));
    71. // enable widget signals
    72. slider.blockSignals(false);
    73. spinbox.blockSignals(false);
    74. checkbox.blockSignals(false);
    75. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 20th March 2011 at 17:14. Reason: changed [quote] to [code]

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: flashing widgets

    Could you explain why you don't pass the parent pointer to QWidget constructor? How do you put the PaniniParameters widget in its parent?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Aug 2008
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: flashing widgets

    PaniniParameters does not need a parent because it is never shown, does not emit any signals, and its slots all call global functions. I create it parentless because otherwise it shows as a black rectangle in the upper left corner of its parent (which is a QGLWidget). However, passing its parent pointer to the QWidget c'tor has no effect on the flashing that I can see.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: flashing widgets

    Quote Originally Posted by tksharpless View Post
    PaniniParameters does not need a parent because it is never shown,
    So why is it a widget?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Aug 2008
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: flashing widgets

    That's what I thought. At first I declared : public QObject. But a QWidget c'tor will not accept a QObject * as parent, so it could not create the controls as its children until I made it a QWidget. This is an inconsistency in Qt, since connectSlotsByName() ( as well as signals and slots themselves ) belong to QObject and don't logically need a QWidget. But tha's how it is...

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: flashing widgets

    Quote Originally Posted by tksharpless View Post
    That's what I thought. At first I declared : public QObject. But a QWidget c'tor will not accept a QObject * as parent, so it could not create the controls as its children until I made it a QWidget.
    Why should it create the controls as its own children? I think I completely miss the point of what you are doing. I don't even see the reason what you need this extra object for.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Aug 2008
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: flashing widgets

    Why should it create the controls as its own children? I think I completely miss the point of what you are doing. I don't even see the reason what you need this extra object for.
    No doubt there are alternatives. But my question was about getting rid of little flashing window frames....

Similar Threads

  1. Replies: 2
    Last Post: 16th December 2010, 11:52
  2. [Qt] Flashing / Flutter Window. How to?
    By Xandareva in forum Newbie
    Replies: 1
    Last Post: 7th July 2010, 05:25
  3. Replies: 5
    Last Post: 18th April 2010, 23:31
  4. Flashing cursor causes graphical glitches in the GUI
    By gboelter in forum Qt Programming
    Replies: 0
    Last Post: 29th October 2009, 03:48
  5. Screen Flashing
    By arunvv in forum Newbie
    Replies: 7
    Last Post: 29th July 2008, 22:45

Tags for this Thread

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.