• Antelope Release 5.9 Mac OS X 10.13.2 2019-05-01

 

NAME

BQTableview - BRTT Qt graphics class for displaying data in a table

SYNOPSIS


-lbqplot -lbanner -lbrttutil $(STOCKLIB)

#include "BQ.h"

DESCRIPTION

BQTableview objects are used to display data in tables using the QTableView class.

This class inherits the BQConfigure class which is itself a subclass of the BUConfigure class with extensions to process Qt colors and fonts. The configure methods are implemented in the BUConfigure parent (see BUConfigure(3)).

This class behaves mainly like the QTableView class with a few exceptions.

INHERITS FROM

QTableView, BQConfigure

CONSTRUCTOR

BQTableview(QWidget *parent);

Where "parent" is the QWidget parent for this object.

METHODS INHERITED FROM BQConfigure

BQTableview METHODS

OBJECT CONFIGURATION PARAMETERS

EXAMPLE

Following is a simple c++ example.


#include "BQ.h"

class MyTableview : public BQTableview {
public:
    MyTableview (QWidget *parent) : BQTableview (parent) {}

    QVariant callback (QStringList request);
};

QVariant MyTableview::callback (QStringList request) {
    if (request[0] == "headerdata") {
        if (request[2] == "horizontal") {
            int col = request[1].toInt();
            return QVariant("col "+request[1]);;
        }
        return QVariant();
    }
    if (request[0] == "data") {
        return QVariant (request[1]);
    }
    if (request[0] == "foreground") {
        auto l = request[1].split(" ");
        int row = l[0].toInt();
        int col = l[1].toInt();
        switch ((row+col)%3) {
        default:
        case 0:
            return QVariant();
        case 1:
            return QVariant(QColor("blue"));
        case 2:
            return QVariant(QColor("red"));
        }
    }
    if (request[0] == "background") {
        auto l = request[1].split(" ");
        int row = l[0].toInt();
        int col = l[1].toInt();
        switch ((row+col)%3) {
        default:
        case 0:
            return QVariant();
        case 1:
            return QVariant(QColor("pink"));
        case 2:
            return QVariant(QColor("lightblue"));
        }
    }
    if (request[0] == "selection_changed") {
        int row = request[1].toInt();
        printf ("selection %d\n", row);
    }
    return QVariant();
}

int
main (int argc, char **argv)

{
    if (argc != 3) {
        fprintf (stderr, "usage: bqplot_test_tableview nrows ncols\n");
        exit (1);
    }

    int nrows = atoi(argv[1]);
    int ncols = atoi(argv[2]);

    QApplication qapp(argc, argv);

    qapp.setApplicationName("bqplot_test_tableview");

    QWidget *widget = new QWidget();
    widget->setWindowTitle("bqplot_test_tableview");
    widget->show();
    widget->resize (800, 400);

    QGridLayout *layout = new QGridLayout (widget);
    layout->setSpacing (0);
    layout->setContentsMargins (0, 0, 0, 0);
    widget->setLayout (layout);

    MyTableview *tv = new MyTableview(widget);
    tv->configure ("color_hover", "magenta", "font", "courier,18,Bold",
                        "font_header", "arial,14,Normal",
                        "default_hover_interaction", "yes",
                        "show_record_numbers", "yes",
                        NULL);
    tv->setDimensions (nrows, ncols);
    layout->addWidget (tv, 0, 0, 1, 1);

    qapp.exec();

    exit (0);
}


SEE ALSO

bqplot(3), BQConfigure(3)

AUTHOR

Danny Harvey, BRTT
Printer icon