Widgets not displaying. SOLVED



  • I am developing a desktop ap that will run only on a Windows 7 desktop type platform. It has 4 "windows" The two main windows display a moving map and live video feed, respectively. A small window at the top displays information gathered from the mapping functions. The window at the bottom displays menu options. The mapping tool is a 3rd party product and uses openGL to display it's information. I had the map working along with the information display and the menu options but could not get the video to work along with the moving map.

    I tried several options for the video either based on QVideoWidget or using a QLabel within a QWidget. Each worked find independently but none worked when I added them to the full ap. My guess was that since the moving map was using openGL the video also needed to use openGL. So I developed a version of a live video feed based on openGL. It is now working fine.

    However, now both the info window and the menu windows no longer display. Ok, so I need to convert them to also use openGL. I have just completed converting the info display to openGL and added it to the ap. It still doesn't display. The code does display independently so I know it at least works. So now I am stuck again. I really, really could use some advice.

    I am including an image of what the ap should look like. On the actual screen capture the video was not working. I pasted an image that shows what the video would include. Here it is.

    !http://i1371.photobucket.com/albums/ag317/gpuckett/LEAP-Sample-Screen-1-small_zps7adebe82.png(Example of application screen.)!

    You can see the information at the top and the menu at the bottom. The video now shows but not the menu or info.

    Not only is there proprietary 3rd party code involved, there is a ton of code generating this information. And it only does not work when it is all together. So I can't figure out a way to provide a version of working code that duplicates the problem. So what I am asking is for suggestions as to what might be causing this to happen.

    The proprietary tool is highly threaded to avoid locking the ui. I did the same with the video. Everything runs in a separate thread and sends captured images to the ui thread through slots and signals. The info and menu windows have little functionality. The menu window simply emits signals as buttons are selected and the info window receives a signal and updates the info fields.

    I don't even know what to look for now that I have the info window converted to openGL and it stil doesn't work.



  • Here is the code that displays the data:

    @#ifndef FOLLOWINFODISPLAYWIDGET_H
    #define FOLLOWINFODISPLAYWIDGET_H

    #include "globals.h"

    #include <QGLWidget>
    #include <QGraphicsView>
    #include <QGraphicsScene>
    #include <QGraphicsSimpleTextItem>
    #include <QFont>
    #include <QRect>

    class FollowInfoDisplayWidget : public QGraphicsView
    {
    Q_OBJECT
    public:
    explicit FollowInfoDisplayWidget(QRect&, QWidget *parent = 0);
    ~FollowInfoDisplayWidget();

    private:
    QGraphicsSimpleTextItem* genHeader(QString&, int, int);
    QGraphicsSimpleTextItem* genInfoText(QString&, int, int);
    QGraphicsScene scene;
    QGLWidget
    glWidget_;

    QGraphicsSimpleTextItem* lat;
    QGraphicsSimpleTextItem* lon;
    QGraphicsSimpleTextItem* speed;
    QGraphicsSimpleTextItem* track;
    QGraphicsSimpleTextItem* gpsStatus;
    
    QGraphicsSimpleTextItem* latHdr;
    QGraphicsSimpleTextItem* lonHdr;
    QGraphicsSimpleTextItem* speedHdr;
    QGraphicsSimpleTextItem* trackHdr;
    QGraphicsSimpleTextItem* gpsHdr;
    
    QFont hdrFont;
    QFont infoFont;
    QBrush grayBrush;
    

    public slots:
    void updateInfo(FollowData*);

    };

    #endif // FOLLOWINFODISPLAYWIDGET_H
    @

    @#include "followinfodisplaywidget.h"

    #include <QGraphicsScene>
    #include <QGLFormat>
    #include <QRectF>

    #include <QDebug>

    FollowInfoDisplayWidget::FollowInfoDisplayWidget(QRect &rect, QWidget *parent) :
    QGraphicsView(parent),
    grayBrush(Qt::gray),
    hdrFont("Arial"),
    infoFont("Arial")
    {
    // qDebug() << "@FollowInfoDisplayWidget constructor";

    this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setStyleSheet("QGraphicsView{border-style:none;}");
    this->glWidget_ = new QGLWidget(QGLFormat(QGL::SampleBuffers));
    this->setViewport(glWidget_);
    setAutoFillBackground(false);
    this->glWidget_->setAutoFillBackground(false);
    this->scene = new QGraphicsScene(this);
    this->setScene(this->scene);
    
    this->setSceneRect(QRectF(rect));
    this->scene->setBackgroundBrush(QBrush(QColor(221,221,221), Qt::SolidPattern));
    
    this->hdrFont.setPointSize(10);
    this->hdrFont.setWeight(75);
    this->hdrFont.setBold(true);
    
    this->infoFont.setPointSize(14);
    this->infoFont.setWeight(95);
    this->infoFont.setBold(true);
    
    this->latHdr = genHeader(QString("Lat"), 10,1);
    this->lonHdr = genHeader(QString("Lon"), 130,1);
    this->speedHdr = genHeader(QString("Speed"), 250,1);
    this->trackHdr = genHeader(QString("Track"), 370,1);
    this->gpsHdr = genHeader(QString("GPS"), 490,1);
    
    this->lat = genInfoText(QString("*****"), 10,16);
    this->lon = genInfoText(QString("*****"), 130,16);
    this->speed = genInfoText(QString("*****"), 250,16);
    this->track = genInfoText(QString("*****"), 370,16);
    this->gpsStatus = genInfoText(QString("*****"), 490,16);
    
    this->scene->update();
    

    }

    FollowInfoDisplayWidget::~FollowInfoDisplayWidget()
    {
    // qDebug() << "@FollowInfoDisplayWidget destructor";
    }

    QGraphicsSimpleTextItem* FollowInfoDisplayWidget::genHeader(QString& text, int x, int y)
    {
    QGraphicsSimpleTextItem* rtn = scene->addSimpleText(text, hdrFont);
    // rtn->setFlag(QGraphicsItem::ItemIsMovable);
    rtn->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
    rtn->setBrush(this->grayBrush);
    rtn->setPos(x,y);

    return rtn;
    

    }

    QGraphicsSimpleTextItem* FollowInfoDisplayWidget::genInfoText(QString& text, int x, int y)
    {
    QGraphicsSimpleTextItem* rtn = scene->addSimpleText(text, infoFont);
    // rtn->setFlag(QGraphicsItem::ItemIsMovable);
    rtn->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
    rtn->setBrush(this->grayBrush);
    rtn->setPos(x,y);

    return rtn;
    

    }

    void FollowInfoDisplayWidget::updateInfo(FollowData* newInfo)
    {
    this->lat->setText(QString::number(newInfo->lat));
    this->lon->setText(QString::number(newInfo->lon));
    this->speed->setText(QString::number(newInfo->speed));
    this->track->setText(QString::number(newInfo->track));
    this->gpsStatus->setText(newInfo->gpsStatus);
    this->scene->update();
    }
    @



  • Sitting watching a game yesterday evening when an idea popped into my mind. Just maybe I wasn't properly initializing the qrect parm that the scene needs. I was right it was initialized to zeros. I fixed that and it is not working fine. I spent 2 days trying to debug this. It's amazing how the most simple issues can be the most difficult to resolve.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.