2016-06-28

Dependency Injected into the world of C#

Quite recently I have begun to learn Visual C#.  Even more recently I have started to learn WPF and how to incorporate Dependency Injection (D.I.) in my code.  Jolly good times.  I will come back with some insights and examples and possibly just some notes for myself that will help clarify what I am learning.  Already, it is interesting to see that I have already used some of these concepts in some fashion or another, but not outright.

One thing is for sure, as usual, the tutorials and documentation are absolutely TERRIBLE.  One I read recently was named "Super Simple Example of ..."  The writer had no concept of grammar, misspelled words constantly, had typos with the wrong words all over the article, and the "simple" example he claimed to be showing went WAY outside of the scope of the topic, brought in a third party API, used snippets of code instead of complete code, and had rambled and bumbled through about 10 entirely disparate programming concepts by the bottom of the first page.  THIS, my friends, is par for the course on the internet and in all of the programming world.  IF only those who know, knew how to explain WHAT they know to someone else.  Alas, this is rarely the case.  All to often, in the end, I find myself reading "official" Microsoft documentation (gag me with a spoon) and running back and forth between programming dictionaries, Wikipedia entries and scanning through Stack Overflow, desperately looking for coherent (but comprehensive) definitions of every other word in the documentation.

One of the cardinal rules for writing actual speaking language dictionaries is that you cannot use the word itself in its definition and that you should avoid, at all costs, using closely related, but just as obscure, words and/or colloquialisms from the same removed and little known dialects.  For instance you don't define a codger as a zany nutter, because those terms are also only fully understood if you ALREADY speak the dialect.  While speaking in jargon is perfectly acceptable when at work in one's profession, you are being either inconsiderate, out-rightly obnoxious, or completely oblivious if you are using jargon to explain jargon inside of a tutorial that claims to introduce new concepts.  Even the simplest of children can see that this will only lead to going around in circles forever.

Let's hope I can sift through the roadblocks, circular logic explanations, and A is A definitions as quickly as possible and get to the nuts and bolts underneath it all, and that I can share a few bits of information along the way.  The inter-webs are in dire need of some serious decoding back to reality.

2013-03-07

QML Resizable rectangle from scratch


It has been forever since I've posted anything on my blog.  Apologies to my follower...  Meanwhile, I have learned quite a lot about QML and QtQuick over the past 6 months or so.  I will have to go dig through my code and find some snippets that I think will be helpful to those joining the Qt universe.

This is a (relatively) simple Item I created which allows the user to click any one of the four walls and drag it to resize the rectangle.  You can also left click on the rectangle and drag it around.  This example does NOT include any limitations to dragging, so if you can pretty much destroy the rectangle by dragging one wall right over the opposite wall.  However, I thought it best to post something simple rather than something more complicated and hard to read for newcomers.  Relationships between anchors and QML objects can get quite confusing fast, and you have to avoid anchor loops.  This is nothing more than an example of multiple anchors working together which actually works, but is not finished product.  


Maybe someone will get some use out of it.


Cheers!
-----------------------------------------------------------------------------

//import QtQuick 2.0
import QtQuick 1.1

 Item {
    id: resizeRectItem
    property real rectWidth
    property real rectHeight

    rectWidth: rightWall.x - leftWall.x
    rectHeight: bottomWall.y - topWall.y
    //opacity: 1

    Rectangle {
        id: resizeRect
        width: rectWidth
        height: rectHeight
        color: "blue"
        anchors.right: rightWall.left
        anchors.bottom: bottomWall.top
        anchors.top: topWall.bottom
        anchors.left: leftWall.right
    }
    MouseArea {
        id: resizeRectDragMA
        width: rectWidth -5
        height: rectHeight -5
        anchors.centerIn: parent
        drag.target: resizeRectItem
        drag.axis: Drag.XandYAxis

        onPressed: {
            resizeRect.color = "green"
            resizeRectItem.anchors.centerIn = null
        }
        onReleased: {
            resizeRect.color = "blue"
        }
    }

    Rectangle {
        id: topWall
        x: -100
        y: -100
        width: rectWidth
        height: 4
        color: "red"
    }
    MouseArea {
        id: topWallMA
        anchors.fill: topWall
        drag.target: topWall
        drag.axis: Drag.YAxis
        onPressed: {
            leftWall.anchors.top = topWall.bottom
            rightWall.anchors.top = topWall.bottom
        }
    }
    Rectangle {
        id: bottomWall
        x:-100
        y: 100
        width: rectWidth
        height: 4
        color: "purple"
    }
    MouseArea {
        id: bottomWallMA
        anchors.fill: bottomWall
        drag.target: bottomWall
        drag.axis: Drag.YAxis
        onPressed: {
            leftWall.anchors.bottom = bottomWall.top
            rightWall.anchors.bottom = bottomWall.top
        }
    }
    Rectangle {
        id: leftWall
        x: -100
        y: -100
        width: 4
        height: rectHeight
        color: "yellow"
    }
    MouseArea {
        id: leftWallMA
        anchors.fill: leftWall
        drag.target: leftWall
        drag.axis: Drag.XAxis
        onPressed: {
            topWall.anchors.left = leftWall.right
            bottomWall.anchors.left = leftWall.right
        }
    }
    Rectangle {
        id: rightWall
        x: 100
        y: -100
        width: 4
        height: rectHeight
        color: "orange"
    }
    MouseArea {
        id: rightWallMA
        anchors.fill: rightWall
        drag.target: rightWall
        drag.axis: Drag.XAxis
        onPressed: {
            topWall.anchors.right = rightWall.left
            bottomWall.anchors.right = rightWall.left
        }
    }
    states: [
        State {
             name: "hide"
             PropertyChanges {
                 target: resizeRectItem
                 opacity: 0.0
             }
        }
    ]
}

2012-10-25

Eclipse Juno problem building Android NDK

When building code from the Android NDK Beginners Guide, simply trying to get a tutorial on OpenSL to run, I ran into some freaky and troublesome bugs with Eclipse.

Code from Chapters 1-5 built without a hitch.  Starting with Chap. 6,  I started having strange intermittent problems. I could import a project, build it and run it, but then I'd do a double take when errors started popping up all over the place, without having made any changes.

I was getting "Field could not be resolved" and "Function could not be resolved" under the Problems tab whenever I tried to build the project.  If I build from the command line, I can get the project to "Run as Android Project" even right inside Eclipse, however, as soon as I open a file for editing, little red error X's start popping up all over everything.  I spent hours and hours trying to check paths and properties, and project configuration, and even my .bashrc and .profile files.  ANYTHING to hunt down and fix this.

Finally, I went to Project/Properties/C-C++ General/Code Analysis and un-checked a couple boxes:
Field could not be resolved
Function could not be resolved


NOT an ideal solution, because now I won't get nice error highlighting for miss-spelled function names etc... BUT now it works inside Eclipse.  This can be set on either a Workspace or Project level, by the way.

Apparently the issue is with the Indexer.  The Eclipse Juno Indexer has a bug where in some situations it will give erroneous validation.  This, in turn, log-jams the build/run process, stopping it in it's tracks based on imaginary errors.  Another way to get around it is to simply right-click on the errors in the "Problems" Tab at the bottom of Eclipse, and delete them.

I'll be doing some updates to see if this bug has already been addressed, I hope so.

2012-10-18

Android NDK R7 major issue glDrawTexfOES

Howdy peoples.  Been a minute since I last posted.

In the process of learning the Android NDK, I've run into a potentially immensely frustrating issue, especially for anyone just trying to learn.  This problem had me stumped literally for days.  Until I brought it to my brother's attention and he found this post:

https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/Inip9SFiRZs

I was attempting to build and run, in Eclipse, some tutorial code from the Android NDK Beginners Guide.  Chapters 6 and 7 to be exact.  I started receiving errors like this:


Function 'glDrawTexfOES' could not be resolved

All of the errors were acting as if the libraries simply were not there, but they were there and the make files appeared to all be in order.

Apparently, the issue mentioned in the Google groups post above, extends to the usage of ANY extension libraries post R6.

Currently, my code is building and running after I changed the Android.mk file to include this line:

LOCAL_CFLAGS    := -DRAPIDXML_NO_EXCEPTIONS -DGL_GLEXT_PROTOTYPES

instead of:
LOCAL_CFLAGS    := -DRAPIDXML_NO_EXCEPTIONS

I may come back and post more about this later, because I may want to add more specifics about the errors I received before the fix.

I want to make one thing clear.  Although Eclipse certainly was not helpful in pinpointing the route of this problem, this is not and Eclipse issue, but an Android NDK issue.

UPDATE:
2012/11/06  -- I thought I might as well post this, because it goes right along with the above problem.  I created a short set of instructions for things that need to be done every time I import the tutorial code from the Android NDK Beginner's Guide.  I really don't have time to explain all the reasons why, but I made this list for myself, so I wouldn't forget, and here it is for the public:


Select File/Import
Select the project folder and check the box for copy project to workspace

Open Android.mk, under jni folder, and change this line:

LOCAL_CFLAGS    := -DRAPIDXML_NO_EXCEPTIONS

to this line:

LOCAL_CFLAGS    := -DRAPIDXML_NO_EXCEPTIONS -DGL_GLEXT_PROTOTYPES

Right click on the project and select Android Tools/Fix Project Properties

Then go to project/properties/C/C++ General/code analysis and uncheck:

Field could not be resolved
Function could not be resolved

Or errors will start popping up as soon as you open anything in the editor.  It might run the first time, but as soon as you try to look at it, it will activate the indexer and start throwing up errors.  Apparently the indexer is not designed to recognize NDK code, of some kinds, in an Android development context.  Oh, Eclipse you rascally rabbit you....


2012-09-07

Some thoughts on my philosophy concerning forums


Yeah, this is the editorial section.  Gotta go there some times.

There are far too many forum "gurus" and trolls who have an absolutely TERRIBLE attitude and it shows in the way that they "answer" forum inquiries.  You all know what I am talking about.  Short smart ass replies that say something like, "if you read the documentation...insert annoying tone and useless high level jargon, indecipherable to anyone who doesn't ALREADY know the answer to the posed question bla bla stop bothering me...".  Yes, we all now that guy.  Lots of those guys.

Here is a simple parallel metaphor to explain my philosophy on documentation and the attitude everyone should have if they participate in any capacity in forums:

You can only ever see a movie, for the first time, once. That is why the director has groups come in and view the movie before he puts it out, so that he can get a perspective on how it actually plays to fresh minds, as opposed to the inevitably warped version that will reach his mind after being filtered through all of his knowledge of what he wants the film to be and of what he already has seen countless times while editing. For film directors, this struggle to make something fresh and digestible, even though it is many years old to themselves, is right in front of them at all times. It is obvious. Once you know everything it is difficult to understand what is the needed amount of information to keep the viewer in touch with the narrative of the story and, for instance, what is going on in the heads of the characters at any given moment.  Is this amount enough?  Or am I making assumptions based on my overall knowledge of the complete character including aspects that have not yet been revealed.  A GOOD director is constantly worried about making sure that his message is getting across right now to people BRAND NEW to his story.  Not so much for programmers and IT guys. What do they care about noobs? Noobs should study more, right?

 I disagree. Study is what you do AFTER you are presented with a concept, in order to make it stick in your mind. It is still the job of the teacher, or the documentation, to present that concept clearly and unmistakably and taking into account all the common pitfalls. There is plenty enough gold to be had after the student has been lead to the mine, provided with a pick, and taught how to use it. Uh oh mixed metaphor!

It is wise to always remember that what appears easy to you, may have been easy for you simply because you got lucky enough to come at it from an advantageous angle, or because you had a good teacher, or because you got lucky and did it right the first time, while others may be struggling with shaking off terribly explained paradigms from the last intolerant asshole forum guru that gave them bad "advice" by giving them incomplete information.  If you get lost on the way to going somewhere every time you go there and all of the directions you ask for are wrong, then it is likely you will not remember exactly how to get back there the next time you try again.  Too many confusing memories.

So, if you are a forum guru, your abrupt, short, impatient answers may actually be helping to create more confusion, instead of helping, and guess what, it will come back to haunt you in the form of more "stupid" questions.  Yup, there is a good chance that you, or some other cocky, incomplete answer giver in a related thread, are the entire reason why this questioner is so stumped to begin with.  So just answer the stupid questions already.  Frankly, I see more stupid answers than stupid questions.  You cannot assume that someone is lazy just because they ask a question.  Sometimes frustration and overload make simple, basic concepts slip through the cracks.  Sometimes, dealing with a steady stream of flippant asshole forum "gurus" will just plain unbalance the chemical balance in one's brain!  However, from the answer side, if you KNOW the answer and you just flip a tidbit at them without clearly explaining, then you are truly giving a stupid answer.  If you are picturing yourself as Mr. Miyagi, and think that you are somehow imparting wisdom by being mysterious, then you are, again, an idiot.  You are not in an intense training montage from a Hong Kong kung-fu movie, you are answering a technical question in a forum specifically dedicated to that discipline.

Smart answers give clear concise information.  You knew that when you answered questions in school, right?  So what is the problem?  Real people not good enough for your A-game answers?  It baffles me.  Posting something like "I think it is clearly spelled out in the documentation", is a waste of every one's time.  It is the equivalent of answering a school test question with "that is defined quite well in the dictionary".  Imagine actually putting that on a test.  You would obviously get an "F" for that answer.  I am giving you an "F" right now for your incomplete, and/or smug, answer in the forums.  Put up or shut up.

The future belongs to the noobs!    They can be your allies, or your enemies.  You decide.  If you don't believe that it is safe to assume that anyone who is asking a question is trying to learn, then you should not be answering questions in a forum.  Go code by yourself in the dark and play some more WoW.

Cheers!

ultramanjones

2012-09-06

Property Animation in QML

It has been a long time since I put up a post, I'll try to post more often.  I'm posting up some code I wrote to make a button pulse after clicked and then quit pulsing when clicked again.  Simple, but it contains some important examples of syntax and implementation.  I hope somebody finds it useful.  
Start up QtCreator and select File/New File or Project.../Applications/QtQuick Application (Built-in Elements).  Enter a name and then select only Desktop.  Will it work on the other platforms?  Probably, but I haven't tested it on any but Desktop, so that is why I'm suggesting you do the same.  Just copy and paste this code over the main.qml and it should run.


import QtQuick 1.0

Rectangle {
    width: 400
    height: 400

    Rectangle {
        id: applyButton

        width: 100
        height: 30
        border.color: "#4f78a2"
        border.width: 2
        radius: 5
        smooth: true
        anchors.centerIn: parent
        color: "#BFEFFF"
        opacity: 1.0

        Text {
            id:textItem
            anchors.centerIn: parent
            font.pointSize: 12
            font.family: "Helvetica"
            color: "#337777"
            styleColor: "#ffffff"
            style: Text.Raised

            text: "Apply"
        }

        PropertyAnimation {
            id: changeToColor1;
            target: applyButton;
            properties: "color";
            to: "#ffff00";
            duration: 1000
        }

        PropertyAnimation {
            id: changeToColor2;
            target: applyButton;
            properties: "color";
            to: "#BFEFFF";
            duration: 1000
        }

        NumberAnimation {
            id: toFullOpacity
            target: applyButton
            properties: "opacity"
            to: 1
            duration: 250
            exclude: border
        }

        SequentialAnimation {
            id: sequentialOpacity
            running: false

            NumberAnimation {
                id: animateOpacity
                target: applyButton
                properties: "opacity"
                from: .2
                to: 1
                duration: 700
                easing {type: Easing.InOutQuad; }
                exclude: border
            }
            NumberAnimation {
                id: animateOpacity2
                target: applyButton
                properties: "opacity"
                to: .2
                from: 1
                duration: 700
                easing {type: Easing.InOutQuad;}
                exclude: border
            }
            loops: Animation.Infinite
        }

        MouseArea {
            id: applyButtonMA
            anchors.fill: parent
            //hoverEnabled: true
            onClicked: {
                if (sequentialOpacity.running == true)
                {
                    sequentialOpacity.stop()
                    toFullOpacity.start()
                    changeToColor2.start()
                }
                else
                {
                    changeToColor1.start()
                    sequentialOpacity.start()
                }
            }
        }
    }
}

                                         



When you click the button the first time, it will turn to yellow and start to pulse ( the opacity will cycle from 1.0 to 0.1 and back again over and over ).

When you click it again, it will return to it's initial state as a light blue button.  

I really love how you just put an id on an item and then you can refer to it later by that id.  Like:
   sequentialOpacity.stop()

It's quick object notation.  Since sequentialOpacity (my name) is an instance of SequentialAnimation I can use dot notation to access any of SequentialAnimation's functions.

QML is not exactly the "plain english" language that it appears to be.  Even the syntax can get a bit wonky at times and leave me scratching my head as to WHY is this element in this syntax, while all the rest are written a different way.  For example, take this bit of code from above:


            NumberAnimation {
                id: animateOpacity2
                target: applyButton
                properties: "opacity"
                to: .2
                from: 1
                duration: 700
                easing {type: Easing.InOutQuad;}
                exclude: border
            }
Apparently "easing" is an object? All the other properties use the colon notation, but then easing pops in using the syntax of an entire object. It could have been written like this:

 
            NumberAnimation {
                id: animateOpacity2
                target: applyButton
                properties: "opacity"
                to: .2
                from: 1
                duration: 700
                easing {
                   type: Easing.InOutQuad;
                }
                exclude: border
            }
Thinking of easing as a property had me coding with the wrong syntax for a while, and the error messages are not always specific enough to lead to proper correction. Eventually I ran into just one example on the inter-webs with the proper syntax and I fixed it, but it took some digging and sleuthing, and this sort of thing is a serious waste of valuable time.

"exclude: border" does not work either, by the way. I have no idea why. And QtCreator rejected entirely "exclude: border.color". Gave up on that one.

 Anyway, play with this and see if it helps you understand QML a little better. Let me know if you have any suggestions or questions. I've been working with QML for a couple of months now, and I've learned how to do a few things. If you are learning this powerful language ( and possibly Qt alongside of it as well ) then you have probably found that documentation of some of the simplest things is hard to find. I'm one who believes that documentation needs to include comprehensive examples, definitions and references to relative terms if it dares call itself documentation. As "extensive" as the Qt and QML documentation is, it lacks terribly in explanations, clarifications of concepts, and easy to read specific examples. IF you already know what you are doing, then it is an adequate reference, but even then I often run into dead ends.

Here are some more of my thoughts on that whole situation...

Thanks for reading.

 CHEERS! ultramanjones

2012-08-09

Qt Open Source Platform sold/moved to Digia

As per this article at PCMag.com, Nokia has just sold Qt to Digia.

I consider this to be great news.  I was a bit worried that Qt might die or flounder along with Nokia, considering that Nokia has completely lost their minds.  Perhaps more accurately, they have been taken over by a questionable leader, to say the least.  I'll not get into the politics.

I'm hopeful that this will lead to a quick release of Qt 5.0, a full realization of QML tools and standards, and full support for Android (and possibly MeeGo, that would be dreamy!).

So glad to hear that the core team will be kept together.

Great news!

I LIKE it!

2012-08-03

Operator Malfunction

When I was a kid, my bro and I used to always get on my Dad's Commodore 64 and try to program ( or just play games ).  I remember that sometimes we would run out of the "office" and get Dad, who was most likely watching TV or reading in the living room, and we'd say things like, "Dad!  We can't get this stupid thing to work, it keeps hanging up and just not working!", or some similar desperate, oblivious plea.

He would "hrrrumph" as he got up from the floor and start following us back to the computer, whereupon I would hear him say, "Ah... it's probably just operator malfunction."

The first couple times I didn't ask what he meant, because I liked to think that I was smart and I would just figure it out when he showed us what was wrong anyway.

Then one time he said the phrase again, and I realized that I had no idea what he was talking about so I said, "What do you mean by 'operator malfunction'?  What's the operator?"

My brain rapidly shuffled through images of circuit boards, transistors and all manner of mysterious electrical components trying to figure it out.

He poked me in the forehead, holding his finger there, then pushing away as he said,"YOU operate the computer, right?" I watched him slowly smile as he watched the me grasp the concept and then he laughed that belly chuckle, "heh ha!", as I scowled and twisted my face at the idea that it could possibly be my fault.

"Ahhh...", I said, reluctantly, but smiling as we sat down to figure out the problem.

Sometimes, after that,  he would hold his finger up in the air like Einstein and proclaim, "Operator Malfunction!"

To this day, I find that the vast majority of my computing problems are due to "operator malfunction".

Miss you Dad.

2012-07-13

QTreeView in QtQuick/QML Implementation

Okay, so in my last post I posted a duplicate of my question over on the Qt Dev Forums.  Thankfully someone answered quickly and I was able to implement a solution.  Mind you, it still has all sorts of kinks and functions that need to be fixed or realized, but it's a start.  Considering how much time I spent trying to get this to work, I figured that this is one of those things that I really want to share with the community, so before I delve in deep, I thought I'd stop for a second and post the code to my test application.

All this app does is show a QTreeView using QML.  Essentially, it is a boiled down plugin for QML.  The QTreeView class is derived from QWidget.  The QDeclarativeView where my QML "lives" only accepts elements that are derived from QGraphicsObject.  To solve this problem I have wrapped the QTreeView in a QGraphicsProxyWidget.

It sounds complicated, but it really isn't.  Without ever having seen it done however, it was quite difficult to discover,  especially for the nooborn like me.  Answers are much simpler to find once you know what questions to ask.  IMHO it is important to always remember this fact lest we start to labor under the misconception that we are actually intelligent beings or that we ourselves are awesome because we know so muich.  What follows are the terrible diseases that go by many names including "noobphobia", "lorditoverallsia", "assholiosis", and "I-have-forgotten-plain-english-but-I-think-that-using-technical-terms-makes-me-look-smart-so-no-one-knows-what-I-am-saying-blindness".  Just take a look around the forums and through the comments all over the web and you will see that these diseases are spreading like that virus that causes people to turn into flesh eating zombies in the movies.  I think I'd prefer the zombies....

Anyway, here is the code.  Enjoy.  If you have any questions, I'll try to answer, but I'm a noob too, so no promises peeps!

I am using Qt Creator 5.0 Based on Qt 4.8.1 (64 bit) according to Help/About Qt Creator...


This quick test app was created by going to File/New File or Project.../Applications/Qt Quick Application (Built-in Elements). Named the project QTreeTest.  I chose only "Desktop" as my target.


The files I am going to share are:

QTreeTest.pro
testtron.h
treeview.h
testtron.cpp
main.cpp
main.qml
TreeView.qml

I tried to post the code directly to Blogger and it got all wonky of course, so here is a link to a Google Docs folder instead.  Enjoy!

LINK TO ALL THE FILES


NOTE: In order to assign the "treeView" a "hide" state I had to nest it within another rectangle and assign the hide state to the id of that rectangle. The TreeView will reject direct state assignments.
I sure hope this helps somebody. I'm going to come back and clean this up a bit on Monday. Right now, it is almost 6:00 PM and it is FRIDAY! Woo hoo! I am outta here! Cheers!

2012-07-12

QTreeView in QML question (posted to Qt Developer Network too)

UPDATE:  See my later post here for the answer(s) to this question.  Or at least a start.

Hello everybody.  Help!  I'm trying to incorporate a Model/View into an application using QTreeView, QFileSystemModel and qmlRegisterType to create the QTreeView plugin.

If my main.qml looks like this:

import QtQuick 1.1
import TreeView_Plugin 1.0

    TreeView {
        id: myTreeView
        allColumnsShowFocus: true

    }

I get a QTreeView displayed looking like this:



However, when my main.qml looks like this:

import QtQuick 1.1
import TreeView_Plugin 1.0

Rectangle {
    id:myRect
    width: 400
    height: 400

    TreeView {
        id: myTreeView
        allColumnsShowFocus: true
    }
}

All I get is this...


I am not able to insert the "TreeView" into the rest of my QML and I can't figure out why.
If I try to add a property change to x, y, width or height, for example:

    TreeView {
        id: myTreeView
        x: 15
        y: 15
        allColumnsShowFocus: true
    }


I get error:  Invalid property assignment: "x" is a read-only property

Of course I will post plenty more code if someone thinks they might be able to help.

The application already uses a QDeclarativeView with an OpenGL backend like so:

QGLWidget *glWidget = new QGLWidget(this); 
setViewport(glWidget); 
 setViewportUpdateMode(QGraphicsView::FullViewportUpdate);


There is of course a bit more code involving setting the FileSystemModel, etc, but I don't believe it is relevant.  I am really quite baffled here.  Obviously, I need the QTreeView to show within the rest of my QML or there really is no point.

If anyone could point me to a way to do this, I would very much appreciate it.  I'm pretty new to Qt and I readily admit that I sometimes have no idea what is going on "under the hood", especially when it comes to the whole MOC file paradigm.

Whatever way I can get this done is fine with me.  I really thought the plugin (qmlRegisterType) method was the way to go, because I'm using it to create an OpenGL window for animations in a separate part of the app, but, as you can see, it ain't working.

Thanks for your help!
------------------------------------
UPDATE  2012-07-13:
I received an answer in the Qt Dev Forums.  Here's a link.
This looks promising, because I was already thinking I would probably have to wrap the class/object in another object in order to get QDeclarativeView to accept it.

What I did not see until after I posted this yesterday, is that QtCreator is producing a warning when I run the first example above (the one WITH the QTreeView displayed).  I don't have it in front of me but it was something along the lines of QDeclarativeView only supports objects derived from QGraphicsObject.  QTreeWidget is NOT a QGraphicsObject, it is derived from QWidget.

I'll let you know what I get working.

I know it's a bit odd posting a question like this, but now you can see the sort of process I go through on a daily basis in the world of programming.  The eternally nooborn, learning never ends.  (did I just coin a word?)