Dear visitor who can read English
This page is a page translated automatically by Google AJAX Language API.
Please comment to this page if you could not understand. A PERSON will review this page .
I think that you will be able to understand this page later. Please give a little time to us.
Best regards,
This site is support & information site of WEB,and Software. This site might help you that create software or Web Site…perhaps?[:]
This class will be entrusted the key control.
QStyledItemDelegate is used here, QTableWidget that can also be used, QTreeWidget can also be used.
The same class is available.
So, QStyledItemDelegate to inherit, let's create a class.
This is, to override a virtual function, respectively, QPlainTextEdit and control.
createEditor - This method is called when the input state, passed by this method appears as a QWidget as a screen.
setEditorData - This method is called when you enter the initial configuration screen.
Here, we present QTableWidget initializes the information of the cell.
setModelData - This method is called when you have finished the editing screen.
Here, the current QTableWidget input and output information to the cells.
#include <QtGui>#include "MultiDelegate.h"int main(int argc,char*argv[]){QApplication app(argc, argv);QTableWidget tableWidget(3,3);
tableWidget.setItemDelegate(new MultiDelegate);// set edit trigger event
tableWidget.setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::SelectedClicked|QAbstractItemView::EditKeyPressed);// set titleQStringList headerLabels;
headerLabels <<"Name"<<"Attribute"<<"Comment";
tableWidget.setHorizontalHeaderLabels(headerLabels);QTableWidgetItem*item[3];// set sample data values.for(int nrow =0; nrow<3; nrow++){
item[0]=newQTableWidgetItem(QString("sample item name #%1").arg(nrow+1));
item[1]=newQTableWidgetItem(QString("att #%1").arg(nrow+1));
item[2]=newQTableWidgetItem(QString("comment #%1\nreturn ").arg(nrow+1));for(int ncol=0;ncol<3;ncol++){
tableWidget.setItem(nrow, ncol, item[ncol]);}}// fit of column size at contents.
tableWidget.resizeColumnsToContents();
tableWidget.resize(500,300);// table show.
tableWidget.show();return app.exec();}
Line 10, setItemDelegate in, Delegate only are associated with the class.
And compile it and run, you'll see a screen like the following.
The work, double-click the mouse, the input state, the screen is operating as expected.
And actually try the action, unfortunately, "Enter" will close the entry screen and enter.
Using QTextEdit as QPlainTextEdit, "Enter" to enter the input screen does not close.
If you override 'eventFilter' method, this window will not close when you input 'Enter' key.
For example, as the following.
eventFilter came into the event, the key event, "Enter" key inputs cases, QPlainTextEdit to add information to the new line and end the process.
Return to the true value is specified, where it means that the processing event, this event h, will be destroyed.
And compile it and run, you will also enter閉JINAKU enter a new line.
This time, QTableWidget we customize the type of treatment.
In addition to the above EXCEL can also Ctrl + Enter to start a new line.
(Included in the sample source)
Also, QPlainTextEdit QComboBox can also be used to replace.
(Basically, if QWidget derived class, you can use in their own class) QTableWidget is a good class to use a variety of applications and would be spread.
This way, often to read the document, it is not surprising.
But who is to skim through the manual as I was, surprisingly, you may get addicted.
If you have noticed something, I would appreciate comments.
April 28th, 2019 @ 18:48:24
33行目は、セルの多いさを内容にあわせて縦横ともに拡大・縮小するように指示しています。
-> 大きさ
April 28th, 2019 @ 18:53:46
2頁目は同じ内容に見受けられます。
戻り値にtrueを指定すると、ここで、イベントが処理されたことを意味しますので、 このイベントh、破棄されます。
-> このイベントは、
May 2nd, 2019 @ 11:44:33
また、QPlainTextEditをQComboBoxの置き換えて使用することもできます。(基本的にQWidgetの派生クラスであれば、独自のクラスでも使えます)
助詞と句点の位置がおかしいと思います。
-> また、QPlainTextEditをQComboBoxに置き換えて使用することもできます(基本的にQWidgetの派生クラスであれば、独自のクラスでも使えます)。