Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. A few design questions...

A few design questions...

Scheduled Pinned Locked Moved General and Desktop
127 Posts 7 Posters 87.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mzimmers
    wrote on 6 Apr 2011, 00:54 last edited by
    #77

    Update: I reread your post above, and discovered that I'd missed the part about no arguments to the notifier signal. That got me halfway home. The other problem was in my .qml file, specifically this line:

    @ onShaperOutIChanged: {
    @

    I had put a small "s" on shaper, since that's the precise (non)capitalization of the routine name, but it didn't like that. (The error message scrolled past too quickly for me to notice at first.) Replacing it with a capital "S" makes it work...but I don't understand why. If you could shed some light on this, that would be great.

    Now that it's working, I'd like to start playing with the formatting of the display. Is this typically done in design mode, or just by editing the QML file? I'd like to change the size of the inner rectangle, the color(s) of the background, text placement, that kind of stuff. Probably through Design mode, right?

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on 6 Apr 2011, 08:47 last edited by
      #78

      You connect statement does not match the signature of your signal. The error message you posted implies that you used an int as an argument in the connect but your header file shows the signal has no arguments (as indeed it should not).

      Change your connect statement that hooks up to the shaperOutIChanged() signal to have no mention of an int argument.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mzimmers
        wrote on 7 Apr 2011, 15:58 last edited by
        #79

        Hi, Zap -

        I got that issue fixed. When you get time, I'd appreciate your feedback on the questions I posted above. I think I'm about ready to consider this thread solved.

        Thanks for all the help.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on 7 Apr 2011, 16:04 last edited by
          #80

          [quote author="mzimmers" date="1302051296"]Update: I reread your post above, and discovered that I'd missed the part about no arguments to the notifier signal. That got me halfway home. The other problem was in my .qml file, specifically this line:

          @ onShaperOutIChanged: {
          @

          I had put a small "s" on shaper, since that's the precise (non)capitalization of the routine name, but it didn't like that. (The error message scrolled past too quickly for me to notice at first.) Replacing it with a capital "S" makes it work...but I don't understand why. If you could shed some light on this, that would be great.
          [/quote]
          That's how Quick works: it automatically creates a camelcase name for the signal.

          [quote]Now that it's working, I'd like to start playing with the formatting of the display. Is this typically done in design mode, or just by editing the QML file? I'd like to change the size of the inner rectangle, the color(s) of the background, text placement, that kind of stuff. Probably through Design mode, right?[/quote]
          There is no established practice for that. QML is too new, and the designer is very new too. Do whatever feels right to you: modify your design in "code" (QML) or visually.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mzimmers
            wrote on 7 Apr 2011, 16:25 last edited by
            #81

            OK, thanks, Andre. So, to try to sum this all up, it appears that in this thread, we've explored two ways to create and maintain UIs: using a widget, and using the PROPERTY macros.

            Does the use of the latter method obviate the need for the former?

            And, if I want to duplicate the QML method for displaying a second value, that means that I duplicate:

            • the Q_PROPERTY macros
            • the methods for setting/getting the member variable (and its string)
            • the connect statement within the Soc constructor

            Did I leave anything out?

            Thanks.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on 7 Apr 2011, 17:20 last edited by
              #82

              [quote author="mzimmers" date="1302193514"]OK, thanks, Andre. So, to try to sum this all up, it appears that in this thread, we've explored two ways to create and maintain UIs: using a widget, and using the PROPERTY macros.[/quote]
              Those are not two different ways of creating UI's. Both are techniques very different techniques, and you can use them together.
              [quote]
              Does the use of the latter method obviate the need for the former?
              [/quote]
              No, not even if you compare QML with QWidgets. You can also use tem together. You can create widgets using QML, for example.

              [quote]And, if I want to duplicate the QML method for displaying a second value, that means that I duplicate:

              • the Q_PROPERTY macros
              • the methods for setting/getting the member variable (and its string)
              • the connect statement within the Soc constructor

              Did I leave anything out?
              [/quote]
              That depends a bit. Every value you want to bind to in QML, needs to be a QObject property. For those, you need Q_PROPERTY macro's, including the getters, setters and change signals (which you left out). If you need the connect statement, depends on what that property does exactly. Just make sure you emit the change signal if the value changes.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mzimmers
                wrote on 7 Apr 2011, 17:31 last edited by
                #83

                I'm still trying to learn the terminology here. By "change signals," are you referring to the "emit" statements?

                On a side note, I notice that, in order to display one member, I've needed to add three routines to my Soc class: a get, a set and a getString. If I wanted to display, say, a dozen variables at once, that could make for a rather large source file. Do you have any tips on organizing files for this kind of application?

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on 7 Apr 2011, 17:41 last edited by
                  #84

                  [quote author="mzimmers" date="1302197505"]I'm still trying to learn the terminology here. By "change signals," are you referring to the "emit" statements?[/quote]
                  I was not making myself clear. It should have been notify signals, not change signals. And you need to emit them, obviously.

                  [quote]On a side note, I notice that, in order to display one member, I've needed to add three routines to my Soc class: a get, a set and a getString. If I wanted to display, say, a dozen variables at once, that could make for a rather large source file. Do you have any tips on organizing files for this kind of application?[/quote]
                  You don't always need a string version. If you need such a thing often, you can choose another method than adding a string property. Using javascript is one option, or create another simple conversino object, or... For every problem, there are multiple solutions.

                  On the number of methods you need for properties: true, but they can almost all be one-liners, and from QtCreator 2.2 you can have Creator implement them for you :-)

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mzimmers
                    wrote on 7 Apr 2011, 18:03 last edited by
                    #85

                    [quote]I was not making myself clear. It should have been notify signals, not change signals. And you need to emit them, obviously. [/quote]

                    I'm still not sure I know what you're referring to. Isn't the notify signal the one called from the set routine? And, as such, it's generated automatically (I don't write it), right? Or are you talking about something else?

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andre
                      wrote on 7 Apr 2011, 18:17 last edited by
                      #86

                      [quote author="mzimmers" date="1302199414"][quote]I was not making myself clear. It should have been notify signals, not change signals. And you need to emit them, obviously. [/quote]

                      I'm still not sure I know what you're referring to. Isn't the notify signal the one called from the set routine? And, as such, it's generated automatically (I don't write it), right? Or are you talking about something else?[/quote]

                      No, that automatic generation only goes for properties you define in QML, not for properties on QObjects. Those must have notify signals defined (and emitted, of course) for the properties you want to use from QML.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mzimmers
                        wrote on 7 Apr 2011, 18:41 last edited by
                        #87

                        Aargh...I'm sorry to be so dense, but I'm not connecting the dots here. This is what I know I've done to effect a QML display for a single member:

                        used the Q_PROPERTY macro in the .h file for the class

                        created a get and a set for this member

                        declared a (member-name)Changed signal for the class...but did NOT define it

                        put an emit in for this signal in a couple places in the code

                        Plus, of course, all the QML formatting.

                        So...what am I missing here?

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andre
                          wrote on 7 Apr 2011, 19:44 last edited by
                          #88

                          Nothing. Seems to be complete :-)
                          You don't need to define signals, Qt will do that for you (through moc). You did include the Q_OBJECT macro in your Soc class definition, I trust? If not, add it, and re-run qmake and recompile.

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            mzimmers
                            wrote on 7 Apr 2011, 19:53 last edited by
                            #89

                            Oh, right...I guess that should go on the list, too. Thanks, Andre.

                            I think I'm done with this thread. I've got some new questions, but they're more appropriate for a new thread.

                            Once again, thanks to everyone who helped out an old dog trying to learn new tricks.

                            1 Reply Last reply
                            0
                            • Z Offline
                              Z Offline
                              ZapB
                              wrote on 8 Apr 2011, 07:50 last edited by
                              #90

                              Sorry for the delay in answering, I've been out of the office and in meetings a lot.

                              @mzimmers, wrt changing the QML document it is up to you how you do it. I tend to use the text editor rather than the design mode. I have not had a chance to play with the qml design mode recently so it has probably changed a great deal since I tsarted looking at qml.

                              If you find yourself reusing the same pattern over and over in a qml scene then you may want to read up on factoring out the commonality into a custom qml Component. This is akin to having a class in C++.

                              Nokia Certified Qt Specialist
                              Interested in hearing about Qt related work

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                mzimmers
                                wrote on 6 May 2011, 17:59 last edited by
                                #91

                                Hey, Zap...if you're still getting alerts on this thread:

                                I'm trying to move the Qt logic we implemented in this thread from one class (Soc) to another (Filter).

                                I commented out most of the Qt code in the Soc class, but I'm getting a build error that a particular routine isn't declared in the scope of the SoC class. The problem is, it's coming from the moc_Soc.cpp file. Is this enough information for you to tell me what I might have missed?

                                Thanks.

                                1 Reply Last reply
                                0
                                • Z Offline
                                  Z Offline
                                  ZapB
                                  wrote on 6 May 2011, 18:26 last edited by
                                  #92

                                  Can you show me your header files and the snippet of code that the compiler is complaining about please? Plus the entire compiler message would be useful too.

                                  Nokia Certified Qt Specialist
                                  Interested in hearing about Qt related work

                                  1 Reply Last reply
                                  0
                                  • M Offline
                                    M Offline
                                    mzimmers
                                    wrote on 6 May 2011, 18:37 last edited by
                                    #93

                                    Here's the error message:

                                    bq. moc_Soc.cpp: In member function 'virtual int Soc::qt_metacall(QMetaObject::Call, int, void**)':
                                    moc_Soc.cpp:98: error: 'shaperOutIString' was not declared in this scope
                                    moc_Soc.cpp:104: error: 'setShaperOutI' was not declared in this scope

                                    Here's the code snippet from the moc_Soc file:

                                    @#ifndef QT_NO_PROPERTIES
                                    else if (_c == QMetaObject::ReadProperty) {
                                    void *_v = _a[0];
                                    switch (_id) {
                                    case 0: reinterpret_cast< long>(_v) = getShaperOutI(); break;
                                    case 1: reinterpret_cast< QString>(_v) = shaperOutIString(); break;
                                    }
                                    @

                                    (It's complaining about the case 1 line.)

                                    Header files: I'm trying to keep this post brief, but here's the header for the filter class:
                                    @class DemodShaperFilter : public QObject
                                    {
                                    Q_OBJECT
                                    Q_PROPERTY (long shaperOutI
                                    READ getShaperOutI WRITE setShaperOutI NOTIFY shaperOutIChanged)
                                    Q_PROPERTY (QString shaperOutIString
                                    READ shaperOutIString NOTIFY shaperOutIStringChanged)
                                    private:
                                    vector<Cell> cellArrayI;
                                    vector<Cell> cellArrayQ;
                                    long shaperOutI; // for Qt display purposes
                                    public:
                                    DemodShaperFilter(QObject *parent = 0,
                                    long rv = 0); // constructor w/ reset param
                                    DemodShaperFilter(QObject *parent = 0,
                                    const DemodShaperFilter &dsf = 0); // copy constructor
                                    ~DemodShaperFilter(); // destructor
                                    void cycle(long combGainI,
                                    long *shaperCoeffI,
                                    long combGainQ,
                                    long *shaperCoeffQ,
                                    bool clockEnable,
                                    bool resetState);
                                    // void testCycle();
                                    void reset();
                                    long getCoeffs(long *aI, long *aQ);
                                    void display();
                                    void setFilterClockEnable(bool n);
                                    long getDemShpIOut();
                                    long getDemShpQOut();
                                    long getShaperOutI() ;
                                    void setShaperOutI(long i);
                                    QString shaperOutIString();

                                    public slots:
                                    void testCycle();

                                    signals:
                                    void shaperOutIChanged ();
                                    void shaperOutIStringChanged ();
                                    };@

                                    Let me know what else you might need. Thanks...

                                    1 Reply Last reply
                                    0
                                    • Z Offline
                                      Z Offline
                                      ZapB
                                      wrote on 6 May 2011, 18:39 last edited by
                                      #94

                                      It looks as if you still have the Q_PROPERTY() declaration in your soc.h file but that you have already removed all of the other related functionality - the setter, getter and notifier signal. Is that correct?

                                      Make sure you rhave no Q_PROPERTY() stuff left in the soc.h file.

                                      Nokia Certified Qt Specialist
                                      Interested in hearing about Qt related work

                                      1 Reply Last reply
                                      0
                                      • M Offline
                                        M Offline
                                        mzimmers
                                        wrote on 6 May 2011, 18:46 last edited by
                                        #95

                                        Good eye. I removed them, and got rid of that error. Now, I'm getting:
                                        @Undefined symbols:
                                        "vtable for DemodShaperFilter", referenced from:
                                        __ZTV17DemodShaperFilter$non_lazy_ptr in DemodShaperFilter.o
                                        (maybe you meant: __ZTV17DemodShaperFilter$non_lazy_ptr)
                                        "DemodShaperFilter::shaperOutIChanged()", referenced from:
                                        DemodShaperFilter::setShaperOutI(long) in DemodShaperFilter.o
                                        @

                                        This is because I didn't change my connect commands in the widget, isn't it? Now, I have to think about this...the filter object isn't visible to the widget.

                                        1 Reply Last reply
                                        0
                                        • Z Offline
                                          Z Offline
                                          ZapB
                                          wrote on 6 May 2011, 19:10 last edited by
                                          #96

                                          That type of error often occurs when you forget to:

                                          • include the Q_OBJECT macro (which I see you have) or
                                          • forget to add the header file to the HEADERS section of the .pro file or
                                          • forget to re-run qmake after doing so.

                                          Look in your build dir and see if you have a moc_demodshaperfilter.cpp being generated as part of the build process.

                                          Nokia Certified Qt Specialist
                                          Interested in hearing about Qt related work

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved