Results 1 to 7 of 7

Thread: Scope of UI

  1. #1
    Join Date
    Oct 2007
    Posts
    38
    Thanks
    1

    Default Scope of UI

    I'm looking for a way to manage the complexity of multiple strung together signals that eventually reach the object that knows the addresses of all the qwidgets so as to be able to speak to them.

    Some perspective:

    Qt Code:
    1. Class MainWindow : ui_myUI {
    2. slot:
    3. inline void send(const QString text) {
    4. myWidget->send(text);
    5. }
    6. private:
    7. MyClass containedObject;
    8. };
    9.  
    10. Class MyClass{
    11. signal:
    12. void relayText(const QString text);
    13. private:
    14. My2ndClass containedObjectNumber2;
    15. };
    16.  
    17. Class My2ndClass {
    18. //I want to send text through myWidget.
    19. public:
    20. inline void sendText() {
    21. emit: signalToSendText(QString("This is tedious and error prone");
    22. }
    23.  
    24. signal:
    25. void signalToSendText(const QString text);
    26. };
    To copy to clipboard, switch view to plain text mode 

    Can someone talk about how to deal with this without signaling, and relaying signals to slots?

    I have been taking a look at postEvent(), but even there, how do you send an event to a specific widget if you don't know its address?

  2. #2
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Scope of UI

    take a look here
    maybe there is something helpful

  3. #3
    Join Date
    Oct 2007
    Posts
    38
    Thanks
    1

    Default Re: Scope of UI

    It looks like you didn't even know about QT's signals and slots to call methods in ui components. I didn't see anything that pertains to circumventing multiple signals to reach a ui component's slot. This is something that I'm finding extremely annoying, as in order to avoid connecting signals to signals I have to either pass all kinds of pointers or tighten the connection between my classes.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Scope of UI

    Quote Originally Posted by Dumbledore View Post
    It looks like you didn't even know about QT's signals and slots to call methods in ui components.
    There's no point in being rude.

    Quote Originally Posted by Dumbledore View Post
    I didn't see anything that pertains to circumventing multiple signals to reach a ui component's slot. This is something that I'm finding extremely annoying, as in order to avoid connecting signals to signals I have to either pass all kinds of pointers or tighten the connection between my classes.
    As you have noticed yourself, the problem would persist if you used events instead (the same with direct calls), because it isn't a matter of technology, but your design.

    It's hard to propose anything with such abstract example, but maybe you need some central object that will serve as a coordinator? Or maybe you don't need two levels of aggregation?

  5. #5
    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: Scope of UI

    You could do something like this, it's not a good design but will work:
    Qt Code:
    1. class MyClass : public QObject {
    2. public:
    3. //...
    4. bool setupConnections(QObject *obj, const char *recv){
    5. return connect(&containedObjectNumber2, SIGNAL(signalToSendText(const QString &)), obj, recv);
    6. }
    7. private:
    8. My2ndClass containedObjectNumber2;
    9. };
    To copy to clipboard, switch view to plain text mode 

    Then you can call it llike:

    Qt Code:
    1. MyClass *cls;
    2. //...
    3. cls->setupConnections(le, SLOT(setText(const QString &)));
    To copy to clipboard, switch view to plain text mode 

    MyClass doesn't even have to be a QObject subclass...

  6. #6
    Join Date
    Oct 2007
    Posts
    38
    Thanks
    1

    Default Re: Scope of UI

    because it isn't a matter of technology
    I'd have to disagree there. It is not impossible to make connections universal. Unless there is a terrible and unavoidable consequence that is impossible to avoid as a result that I can not think of, it really should be made possible. (It's not like QT hasn't extended C++ before)

    because it isn't a matter of technology, but your design.
    I'm interested to know of a good, general way to design in a way that would avoid connecting signals to signals and the like. Perhaps if you know of books related to this, articles, or anything?

    Cool wysota, but I am in need of a good design.

    P.S. I appologize if I was perceived as being rude. It wasn't my intention.

  7. #7
    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: Scope of UI

    Quote Originally Posted by Dumbledore View Post
    I'm interested to know of a good, general way to design in a way that would avoid connecting signals to signals and the like. Perhaps if you know of books related to this, articles, or anything?

    Cool wysota, but I am in need of a good design.
    So I suggest you listen to Jacek and implement a kind of a broker object that will handle manipulating signals.

    I second what Jacek said - it isn't a matter of technology, it's a matter of language rules and computer design you have to obey.

Similar Threads

  1. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  2. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19
  3. qmake debug/release scope and disabling debugging output
    By No-Nonsense in forum Qt Programming
    Replies: 7
    Last Post: 12th March 2007, 15:48
  4. error: 'connect' was not declared in this scope ??
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 14th January 2007, 15:27
  5. Replies: 3
    Last Post: 4th August 2006, 12:05

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.