JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches
JKQTPEnhancedTableView Class Reference

this class extends the QTableView More...

#include <jkqtpenhancedtableview.h>

Inheritance diagram for JKQTPEnhancedTableView:
[legend]
Collaboration diagram for JKQTPEnhancedTableView:
[legend]

Public Slots

void copySelectionToCSV (int copyrole=Qt::EditRole, bool storeHead=true, const QString &separator=", ", const QChar &decimalpoint='.')
 copy the selected cells' contents to the clipboard as comma separated text
 
void copySelectionToCSVNoHead (int copyrole=Qt::EditRole, const QString &separator=", ", const QChar &decimalpoint='.')
 copy the selected cells' contents to the clipboard as comma separated text, without the header
 
void copySelectionToExcel (int copyrole=Qt::EditRole, bool storeHead=true)
 copy the selected cells' contents to the clipboard, so it can be pasted into Excel
 
void copySelectionToExcelNoHead (int copyrole=Qt::EditRole)
 copy the selected cells' contents to the clipboard, so it can be pasted into Excel, without header
 
void print ()
 print the table contents
 

Signals

void keyPressed (int key, Qt::KeyboardModifiers modifiers, const QString &text)
 emitted when a key is pressed in the context of this widget
 

Public Member Functions

 JKQTPEnhancedTableView (QWidget *parent=nullptr)
 
virtual ~JKQTPEnhancedTableView ()
 
QAction * getActionPrint ()
 return a QAction that prints the table using the methode print()
 
QSizeF getTotalSize () const
 returns the totoal size of the table-view
 
void paint (QPainter &painter, QRect pageRec=QRect())
 draw the contents of the table-view into the given pageRect, using the given painter
 
void print (QPrinter *printer, bool onePageWide=false, bool onePageHigh=false)
 print the contents of the table view
 
QString toHtml (int borderWidth=1, bool non_breaking=false, int fontSizePt=-1) const
 return the contents of the table view as HTML fragment
 

Protected Member Functions

QPrinter * getPrinter (QPrinter *printerIn=nullptr, bool *localPrinter=nullptr)
 select a printer, using a print-selection dialog if necessary
 
virtual void keyPressEvent (QKeyEvent *event)
 handles key presses and reacts to some standard keys
 
void paint (QPainter &painter, double scale, int page, double hhh, double vhw, const QList< int > &pageCols, const QList< int > &pageRows, QPrinter *p=nullptr)
 internal paintig method
 

Protected Attributes

QAction * printAction
 action that calls print()
 

Detailed Description

this class extends the QTableView

This enhanced table view adds some functionality to the Qt class:

  • return HTML code that describes the table (see toHtml() )
  • contains methods to draw the table onto a QPainter: paint()
  • the selected cells may be copied to Excel using the clipboard (Excel will recognize number !) see copySelectionToExcel() and copySelectionToCSV()
  • copySelectionToExcel() is called when the user presses the default copy key combination for your system (e.g. Ctrl+C)
  • print() is called when the user presses the default print key combination for your system (e.g. Ctrl+P)
  • the signal keyPressed() is emitted, when the suer pressed a key

Constructor & Destructor Documentation

◆ JKQTPEnhancedTableView()

JKQTPEnhancedTableView::JKQTPEnhancedTableView ( QWidget *  parent = nullptr)

◆ ~JKQTPEnhancedTableView()

virtual JKQTPEnhancedTableView::~JKQTPEnhancedTableView ( )
virtual

Member Function Documentation

◆ copySelectionToCSV

void JKQTPEnhancedTableView::copySelectionToCSV ( int  copyrole = Qt::EditRole,
bool  storeHead = true,
const QString &  separator = ", ",
const QChar &  decimalpoint = '.' 
)
slot

copy the selected cells' contents to the clipboard as comma separated text

Parameters
copyrolespecifies how the values for copying are extracted (see Qt::ItemDataRole). During the export, this parameter is supplied to function data() of the underlying model.
storeHeaden-/disable storage of the table header
See also
copySelectionToCSVNoHead()
Parameters
separatorseparator between two values (default is a comma)
decimalpointdecimal separator for values (default is a dot)
See also
copySelectionToCSVNoHead()

◆ copySelectionToCSVNoHead

void JKQTPEnhancedTableView::copySelectionToCSVNoHead ( int  copyrole = Qt::EditRole,
const QString &  separator = ", ",
const QChar &  decimalpoint = '.' 
)
slot

copy the selected cells' contents to the clipboard as comma separated text, without the header

Parameters
copyrolespecifies how the values for copying are extracted (see Qt::ItemDataRole). During the export, this parameter is supplied to function data() of the underlying model.
separatorseparator between two values (default is a comma)
decimalpointdecimal separator for values (default is a dot)
See also
copySelectionToCSV()

◆ copySelectionToExcel

void JKQTPEnhancedTableView::copySelectionToExcel ( int  copyrole = Qt::EditRole,
bool  storeHead = true 
)
slot

copy the selected cells' contents to the clipboard, so it can be pasted into Excel

◆ copySelectionToExcelNoHead

void JKQTPEnhancedTableView::copySelectionToExcelNoHead ( int  copyrole = Qt::EditRole)
slot

copy the selected cells' contents to the clipboard, so it can be pasted into Excel, without header

◆ getActionPrint()

QAction * JKQTPEnhancedTableView::getActionPrint ( )
inline

return a QAction that prints the table using the methode print()

See also
print()

◆ getPrinter()

QPrinter * JKQTPEnhancedTableView::getPrinter ( QPrinter *  printerIn = nullptr,
bool *  localPrinter = nullptr 
)
protected

select a printer, using a print-selection dialog if necessary

◆ getTotalSize()

QSizeF JKQTPEnhancedTableView::getTotalSize ( ) const

returns the totoal size of the table-view

See also
paint()

◆ keyPressed

void JKQTPEnhancedTableView::keyPressed ( int  key,
Qt::KeyboardModifiers  modifiers,
const QString &  text 
)
signal

emitted when a key is pressed in the context of this widget

◆ keyPressEvent()

virtual void JKQTPEnhancedTableView::keyPressEvent ( QKeyEvent *  event)
protectedvirtual

handles key presses and reacts to some standard keys

◆ paint() [1/2]

void JKQTPEnhancedTableView::paint ( QPainter &  painter,
double  scale,
int  page,
double  hhh,
double  vhw,
const QList< int > &  pageCols,
const QList< int > &  pageRows,
QPrinter *  p = nullptr 
)
protected

internal paintig method

◆ paint() [2/2]

void JKQTPEnhancedTableView::paint ( QPainter &  painter,
QRect  pageRec = QRect() 
)

draw the contents of the table-view into the given pageRect, using the given painter

The output look like this:

See also
print()

◆ print [1/2]

void JKQTPEnhancedTableView::print ( )
slot

print the table contents

Before printing this function opens a QPrintDialog to select a printer and then opens a second dialog that allows to set different options for the printout:

The printouts look like this:

Depending on the options set in the dialog above, the printout is split over several pages, or not:

Split over pages (onePageWide=false onePageHigh=false)
Print on one page (onePageWide=true onePageHigh=true)

◆ print() [2/2]

void JKQTPEnhancedTableView::print ( QPrinter *  printer,
bool  onePageWide = false,
bool  onePageHigh = false 
)

print the contents of the table view

Parameters
printerthe QPrinter to use for printing the table view
onePageWidelimit the width of the table to a single page, if not set the printout may span several pages
onePageHighlimit the height of the table to a single page, if not set the printout may span several pages

The printouts look like this:

Depending on the options set in the dialog above, the printout is split over several pages, or not:

Split over pages (onePageWide=false onePageHigh=false)
Print on one page (onePageWide=true onePageHigh=true)

◆ toHtml()

QString JKQTPEnhancedTableView::toHtml ( int  borderWidth = 1,
bool  non_breaking = false,
int  fontSizePt = -1 
) const

return the contents of the table view as HTML fragment

Member Data Documentation

◆ printAction

QAction* JKQTPEnhancedTableView::printAction
protected

action that calls print()


The documentation for this class was generated from the following file: