Results 1 to 2 of 2

Thread: TabWidget not showing contents

  1. #1
    Join Date
    Oct 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default TabWidget not showing contents

    First of all hello to everybody, as this is my first post in this forum!

    Now, let's get started!
    I am developing an application on both Linux and Windows.
    The problem I am going to describe happens only on Windows, as on Linux everything runs smoothly.

    You should now that I am developing everything via QT Creator, so I am drawing the GUI in there as well.

    So, the program I am building is a QMainWindow which, on certain condition display another QMainWindow, which is the one giving me problem and which we will call outputViewer. This outputViewer has a QTabWidget as a central widget (set up by me through this->setCentralWidget(tabWidget) ), and this tabWidget has 6 different pages, each one with a scrollArea and a QLabel. In the QLabel I draw some images and i put the QLabel inside the scroll area so that I am able to move it. Then I connect all the scrollbars so that when i move one, all of them are synched.

    The problem is that, when I build the program with the RELEASE configuration, the outputViewer doesn't show anything inside, but the tab bar of the tabWidget. Building through the DEBUG configuration doesn't cause any problem.

    Again, this happens only in windows XP. Linux is perfectly fine with it.

    I am enclosing the .h and .cpp of the class giving me problem, as they are quite small.

    outputviewer.h:

    -----------------------------------
    #ifndef OUTPUTVIEWER_H
    #define OUTPUTVIEWER_H

    #include <QtGui/QMainWindow>
    #include <QImage>
    #include <QLabel>
    #include <QScrollArea>
    #include <QScrollBar>
    #include <QDebug>
    #include <cv.h>
    #include <highgui.h>

    namespace Ui {
    class OutputViewer;
    }

    class OutputViewer : public QMainWindow {
    Q_OBJECT
    public:
    OutputViewer(QWidget *parent = 0);
    ~OutputViewer();
    bool updateViewers(IplImage* segmentedImg, IplImage* erodedImg, IplImage* dilatedImg,
    IplImage* microBlobsImg, IplImage* macroBlobsImg, IplImage* blobsImg);

    protected:
    void changeEvent(QEvent *e);

    private:
    int iplImage2QImage(IplImage*, QImage*);
    bool drawImage(IplImage *img, QImage *drawImg, QLabel *label, QScrollArea *scrollArea);
    Ui::OutputViewer *m_ui;

    private slots:
    void changeHorizontalBars(int value);
    void changeVerticalBars(int value);

    };

    #endif // OUTPUTVIEWER_H
    --------------------------------------------

    outputviewer.cpp
    --------------------------------------------
    #include "outputviewer.h"
    #include "ui_outputviewer.h"

    OutputViewer::OutputViewer(QWidget *parent) :
    QMainWindow(parent),
    m_ui(new Ui::OutputViewer)
    {
    m_ui->setupUi(this);

    m_ui->segmentationScrollArea->setWidget(m_ui->segmentationLabel);
    m_ui->erosionScrollArea->setWidget(m_ui->erosionLabel);
    m_ui->dilationScrollArea->setWidget(m_ui->dilationLabel);
    m_ui->microBlobsScrollArea->setWidget(m_ui->microBlobsLabel);
    m_ui->macroBlobsScrollArea->setWidget(m_ui->macroBlobsLabel);
    m_ui->blobsScrollArea->setWidget(m_ui->blobsLabel);

    setWindowTitle("Output Viewer");
    setWindowIcon(QIcon("logoPiccolo.png"));

    // connect scrollbars to change their value at the same time
    connect(m_ui->segmentationScrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)),
    this, SLOT(changeHorizontalBars(int)));
    connect(m_ui->erosionScrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)),
    this, SLOT(changeHorizontalBars(int)));
    connect(m_ui->dilationScrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)),
    this, SLOT(changeHorizontalBars(int)));
    connect(m_ui->microBlobsScrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)),
    this, SLOT(changeHorizontalBars(int)));
    connect(m_ui->macroBlobsScrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)),
    this, SLOT(changeHorizontalBars(int)));
    connect(m_ui->blobsScrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)),
    this, SLOT(changeHorizontalBars(int)));

    connect(m_ui->segmentationScrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)),
    this, SLOT(changeVerticalBars(int)));
    connect(m_ui->erosionScrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)),
    this, SLOT(changeVerticalBars(int)));
    connect(m_ui->dilationScrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)),
    this, SLOT(changeVerticalBars(int)));
    connect(m_ui->microBlobsScrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)),
    this, SLOT(changeVerticalBars(int)));
    connect(m_ui->macroBlobsScrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)),
    this, SLOT(changeVerticalBars(int)));
    connect(m_ui->blobsScrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)),
    this, SLOT(changeVerticalBars(int)));
    }

    OutputViewer::~OutputViewer()
    {
    delete m_ui;
    }

    void OutputViewer::changeHorizontalBars(int value)
    {
    m_ui->segmentationScrollArea->horizontalScrollBar()->setValue(value);
    m_ui->erosionScrollArea->horizontalScrollBar()->setValue(value);
    m_ui->dilationScrollArea->horizontalScrollBar()->setValue(value);
    m_ui->microBlobsScrollArea->horizontalScrollBar()->setValue(value);
    m_ui->macroBlobsScrollArea->horizontalScrollBar()->setValue(value);
    m_ui->blobsScrollArea->horizontalScrollBar()->setValue(value);
    }

    void OutputViewer::changeVerticalBars(int value)
    {
    m_ui->segmentationScrollArea->verticalScrollBar()->setValue(value);
    m_ui->erosionScrollArea->verticalScrollBar()->setValue(value);
    m_ui->dilationScrollArea->verticalScrollBar()->setValue(value);
    m_ui->microBlobsScrollArea->verticalScrollBar()->setValue(value);
    m_ui->macroBlobsScrollArea->verticalScrollBar()->setValue(value);
    m_ui->blobsScrollArea->verticalScrollBar()->setValue(value);
    }

    void OutputViewer::changeEvent(QEvent *e)
    {
    QMainWindow::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
    m_ui->retranslateUi(this);
    break;
    default:
    break;
    }
    }

    bool OutputViewer::updateViewers(IplImage* segmentedImg, IplImage* erodedImg, IplImage* dilatedImg,
    IplImage* microBlobsImg, IplImage* macroBlobsImg, IplImage* blobsImg)
    /* This function updates all the viewers showing the pictures in input */
    {
    // drawing segmented image
    QImage *displaySegmented = new QImage(segmentedImg->width, segmentedImg->height, QImage::Format_RGB888);
    if (!drawImage(segmentedImg, displaySegmented, m_ui->segmentationLabel, m_ui->segmentationScrollArea))
    return false;

    // darwing eroded image
    QImage *displayEroded = new QImage(erodedImg->width, erodedImg->height, QImage::Format_RGB888);
    if (!drawImage(erodedImg, displayEroded, m_ui->erosionLabel, m_ui->erosionScrollArea))
    return false;

    // darwing dilated image
    QImage *displayDilated = new QImage(dilatedImg->width, dilatedImg->height, QImage::Format_RGB888);
    if (!drawImage(dilatedImg, displayDilated, m_ui->dilationLabel, m_ui->dilationScrollArea))
    return false;

    // darwing micro blobs image
    QImage *displayMicro = new QImage(microBlobsImg->width, microBlobsImg->height, QImage::Format_RGB888);
    if (!drawImage(microBlobsImg, displayMicro, m_ui->microBlobsLabel, m_ui->microBlobsScrollArea))
    return false;

    // darwing macro blobs image
    QImage *displayMacro = new QImage(macroBlobsImg->width, macroBlobsImg->height, QImage::Format_RGB888);
    if (!drawImage(macroBlobsImg, displayMacro, m_ui->macroBlobsLabel, m_ui->macroBlobsScrollArea))
    return false;

    // darwing blobs image
    QImage *displayBlobs = new QImage(blobsImg->width, blobsImg->height, QImage::Format_RGB888);
    if (!drawImage(blobsImg, displayBlobs, m_ui->blobsLabel, m_ui->blobsScrollArea))
    return false;

    return true;
    }

    bool OutputViewer::drawImage(IplImage *img, QImage *drawImg, QLabel *label, QScrollArea *scrollArea)
    /*This function draw an IplImage to a QLabel. It also adjust the corresponding widgets size.*/
    {
    if (img == NULL)
    return false;
    if (iplImage2QImage(img, drawImg)) {
    return false;
    }
    label->setPixmap(QPixmap::fromImage(*drawImg));
    label->setMinimumSize(drawImg->size());
    label->setMaximumSize(drawImg->size());
    delete drawImg;
    scrollArea->setWidgetResizable(true);
    scrollArea->adjustSize();
    adjustSize();
    return true;
    }

    int OutputViewer::iplImage2QImage(IplImage* iplIm, QImage* qIm)
    /* Function that transform an IplImage in a QImage */
    {
    if (iplIm->width != qIm->width() || iplIm->height != qIm->height())
    return 1;
    if (iplIm->nChannels == 3) {
    for (int row = 0; row < iplIm->height; row++) {
    uchar* ptr = (uchar*)(iplIm->imageData + row * iplIm->widthStep);
    uchar* qPtr = (uchar*)(qIm->scanLine(row));
    for (int col = 0; col < iplIm->width; col++) {
    qPtr[3*col + 2] = ptr[3*col];
    qPtr[3*col + 1] = ptr[3*col + 1];
    qPtr[3*col] = ptr[3*col + 2];
    }
    }
    } else if (iplIm->nChannels == 1) {
    for (int row = 0; row < iplIm->height; row++) {
    uchar* ptr = (uchar*)(iplIm->imageData + row * iplIm->widthStep);
    uchar* qPtr = (uchar*)(qIm->scanLine(row));
    for (int col = 0; col < iplIm->width; col++) {
    qPtr[3*col + 2] = ptr[col];
    qPtr[3*col + 1] = ptr[col];
    qPtr[3*col] = ptr[col];
    }
    }
    } else
    return 2;
    return 0;
    }

  2. #2
    Join Date
    Oct 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: TabWidget not showing contents

    Seems no one has faced anything like this!
    Could it be a bug?

Similar Threads

  1. Complex button contents
    By spraff in forum Qt Programming
    Replies: 3
    Last Post: 11th November 2008, 16:17
  2. about qt/embedded widgets showing in ARM platform
    By xianshuiren in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 3rd December 2007, 06:48
  3. Tabwidget not refreshing properly
    By seguprasad in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2007, 13:40

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.