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 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...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 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.


  3. #3
    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....

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

    Default Re: flashing widgets

    To understand why they are flashing one has to understand what is going on in the program. One of the ways to get rid of flashing is to eliminate the reason for flashing which is almost certainly related to how the architecture of your solution looks like. We all have used child widgets many times in our apps and they haven't been flashing so obviously the problem is related to how you use them. So if you want a solution, please answer my question as best as you can. For me it seems your extra object is just some kind of storage for the child widgets you need but it doesn't have to be a widget. Especially if you place it in a QGLWidget and you do something with it which causes a black spot to appear on your GL widget. It is a good guess that you are doing something with your widgets which you are not aware of. For instance you said earlier that you explicitly hide the widgets and yet we can't see that in the code you posted. This is a perfectly good reason as for why your widgets might be flashing. And it would probably be eliminated if the parent-child relationship (obtained through your extra object) between those flashing widgets and widgets that are explicitly or implicitly visible was severed.
    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

    The reason the creating container is a widget rather than a QObject is that I need it to receive signals from the control widgets it creates; and since there are a lot of those, I would like to use the connectSlotsByName method of QMetaObject to connect them. That method requires the signal sources be children of the object whose slots are to be connected to them. But the QWidget c'tor will only accept a QWidget, not a QObject, as its parent. Hence my container object has to be a QWidget. This is almost certainly a scenario the designers of Qt overlooked, or perhaps ruled out; otherwise it should be possible to make a Widget a direct child of an Object.

    I shall now try the alternative of declaring the container a QObject, creating the control widgets parentless, and explicitly connecting their signals. And let you know if that fixes the flashing.

    regards, Tom

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: flashing widgets

    This is almost certainly a scenario the designers of Qt overlooked, or perhaps ruled out; otherwise it should be possible to make a Widget a direct child of an Object.
    You can be assured its the later and not the former.
    It makes no sense to have a visible child (QWidget) to a non visible QObject.
    You might want to have a look at QSignalMapper.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 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 need this containing object in the first place? connectSlotsByName() is not a problem, you can probably force a QObject parent to a QWidget child (however useless this would be) by calling setParent() or you can connect slots by name manually on whatever two objects you want. The point is WHY you want to do all that.
    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.


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

    Default Re: flashing widgets

    I have a class for displaying images, that is non-Qt for sufficient reasons. I wrap it in various QGLwidgets to create different photography apps. It has lots of control parameters, whose functions the app is not going to modify. The Qt object that creates the controls converts messages from those controls into calls to image display methods, using a global pointer to the display object.

    Thus, the app does not need to worry about the image display API. But it is concerned with how the controls are presented to the user, and must place them in various dialogs according to its mission.

    Is that clear enough?

    Re the SignalMapper: Leaving aside that it does not return values from the controls themselves, it requires not one but two explicit connect calls per control group. My problem here seems to result from my trying to avoid having to write any connect calls. I believe that if I were willing to do that, I could use a QObject instead of a QWidget, and the screen flashing would likely go away.

    --Tom

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 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
    I have a class for displaying images, that is non-Qt for sufficient reasons. I wrap it in various QGLwidgets to create different photography apps. It has lots of control parameters, whose functions the app is not going to modify. The Qt object that creates the controls converts messages from those controls into calls to image display methods, using a global pointer to the display object.

    Thus, the app does not need to worry about the image display API. But it is concerned with how the controls are presented to the user, and must place them in various dialogs according to its mission.

    Is that clear enough?
    No, not really. So far I don't see any reason for any artificial behaviour. From what I understand you just need a wrapper over Qt API to fit your non-Qt API. Usually this is handled by a set of factories that return hidden-API objects wrapped into exposed-API objects/classes. Something like:

    Qt Code:
    1. class BrightnessControl {
    2. public:
    3. virtual void adjustBrightness(int level) = 0;
    4. };
    5.  
    6. class BrightnessControlFactory {
    7. public:
    8. virtual BrightnessControl* createControl(...) = 0;
    9. };
    10.  
    11. class QtBrightnessControlFactory : public BrightnessControlFactory {
    12. public:
    13. BrightnessControl *createControl(...) { return new BrightnessControlWidgetOrSomething(...); /* extends BrightnessControl */ }
    14. };
    To copy to clipboard, switch view to plain text mode 

    Then you just manipulate the control using the general interface letting the internal implementation handle the details (emitting signals, calling slots, showing widgets and stuff like that). Of course it's likely createControl() should do more than just return a widget instance. The point is that when you need another brightness manipulator, you call the factory and you have a brightness manipulator. And you can have as many of those as you like.
    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.


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

    Default Re: flashing widgets

    Further information: Making the top class a QObject and creating the control widgets with parent = 0 does not stop the flashing; in fact makes it worse (frames are larger and stay onscreen longer).

    Nor does explicitly hiding the control widget in its c'tor prior to creating any of its child widgets -- in fact that also makes the frames bigger.

    When I step through the c'tor of the top object in gdb, the frames still flash, at unpredictable times not related to that code; and it seems there are calls to QWidget::setVisible() happening in another thread.

    So I would guess this problem is not directly related to the matters we have been discussing. Any further ideas?

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

    Default Re: flashing widgets

    Please provide a minimal compilable example reproducing the problem. I use a lot of Qt based software and non of it is flashing hidden widgets. And certainly no other threads operate on your widgets.
    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.


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

    Default Re: flashing widgets

    Attached, a small QtCreator project that demonstrates the problem on my system (AMD64, WinVista32, Qt 4 Opensource). Look for little flashing windows in upper left corner of screen just before main window appears.

    Thanks, Tom
    Attached Files Attached Files

  13. #13
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: flashing widgets

    In PaniniSlide.cpp the following causes your flash:
    Qt Code:
    1. // set checkbox text, hide it if none
    2. pcheckbox->setText( checkText );
    3. pcheckbox->setVisible( !checkText.isEmpty() );
    To copy to clipboard, switch view to plain text mode 
    You have four controls that pass a non-empty QString.

    To eliminate the flash, try giving pcheckbox a parent:
    Qt Code:
    1. pcheckbox = new QCheckBox(this);
    To copy to clipboard, switch view to plain text mode 

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