QT6 源(153)模型視圖架構里的表格窗體視圖 QTableWidget 篇三:源碼及其元素 QTableWidgetItem 的源代碼帶注釋

(14)本源代碼定義于頭文件 qtablewidget . h 頭文件

#ifndef QTABLEWIDGET_H
#define QTABLEWIDGET_H#include <QtWidgets/qtableview.h>
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qlist.h>
#include <QtCore/qvariant.h>QT_REQUIRE_CONFIG(tablewidget);QT_BEGIN_NAMESPACEclass QTableWidgetSelectionRange
{
public:QTableWidgetSelectionRange() = default;QTableWidgetSelectionRange(int top, int left, int bottom, int right): m_top(top), m_left(left), m_bottom(bottom), m_right(right){}inline int topRow() const { return m_top; }inline int bottomRow() const { return m_bottom; }inline int leftColumn() const { return m_left; }inline int rightColumn() const { return m_right; }inline int rowCount() const { return m_bottom - m_top + 1; }inline int columnCount() const { return m_right - m_left + 1; }
private:int m_top = -1, m_left = -1, m_bottom = -2, m_right = -2;
};class QTableWidget;
class QTableModel;
class QWidgetItemData;
class QTableWidgetItemPrivate;/*
The QTableWidgetItem class provides an item for use with the QTableWidget class.Detailed Description :
表格項用于存儲表格小部件的信息。項目通常包含文本、圖標或復選框。
QTableWidgetltem類是一個方便的類,它在Qt 3中替換了QTableWidgetltem類。
它提供了一個可以與QTableWidgetltem類一起使用的項目。
頂級項目在沒有父項的情況下構建,然后根據行號和列號指定的位置插入:QTableWidgetItem * newItem = new QTableWidgetItem(tr("%1").arg(pow(row, column+1)));tableWidget->setItem(row, column, newItem);每個項目都可以有自己的背景畫筆,這通過`setBackground()、函數來設置。
當前的背景畫筆可以通過background ()、函數來獲取。
每個項目的文本標簽可以使用其特定的字體和畫筆來呈現,這通過`setFont ()'和setForeground)函數進行指定,
并通過`font()`和`foreground()'函數來讀取。默認情況下,項是啟用的,可編輯的,可選擇的,可檢查的,并且既可以作為拖放操作的源,也可以作為落點目標。
每個項的標記可以通過調用setFlags()函數并傳入相應的值(見Qt:ItemFlags)來更改。
可檢查的項可以通過setCheckState()函數進行檢查和取消檢查。
對應的checkState()函數則指示該項當前是否被檢查過。Subclassing :
當子類化 QTableWidgetltem 以提供自定義項時,可以為它們定義新類型,以便它們可以與標準項區分開來.
需要此功能的子類的構造函數需要使用等于或大于 UserType 的新類型值調用基類構造函數。*/class Q_WIDGETS_EXPORT QTableWidgetItem
{friend class QTableWidget;friend class QTableModel;
private:QTableModel * tableModel() const;private: //可見,表格里的條目還有豐富的數據成員,以描述條目里的數據與屬性int                       rtti     ;QList<QWidgetItemData>    values   ; //包含了條目里的數據QTableWidget            * view     ; //本條目屬于哪個表格窗體。QTableWidgetItemPrivate * d        ;Qt::ItemFlags             itemFlags; //本條目的編輯屬性。public:enum ItemType { Type = 0, UserType = 1000 };//Constructs a table item of the specified type that does not belong to any table.//形參 type會賦值給本類的私有數據成員 rtti,以保存本條目的類型。explicit   QTableWidgetItem(int type = Type); //默認類型是 0inline int type() const { return rtti; }//Returns the type passed to the QTableWidgetItem constructor.//Constructs a table item with the given text.explicit   QTableWidgetItem(const QString & text, int type = Type); //有參構造函數explicit   QTableWidgetItem(const QIcon   & icon,const QString & text, int type = Type);QTableWidgetItem(const QTableWidgetItem & other); //copy構造函數QTableWidgetItem & operator=(const QTableWidgetItem & other);//copy賦值運算符函數virtual ~QTableWidgetItem(); //析構函數virtual bool operator< (const QTableWidgetItem & other) const; //無注釋virtual QTableWidgetItem * clone() const; //Creates a copy of the item.//Returns the table widget that contains the item.inline  QTableWidget     * tableWidget() const { return view; }inline int row   () const{   return (view ? view->row(this)    : -1); }inline int column() const{   return (view ? view->column(this) : -1); }//Returns the row of the item in the table.//If the item is not in a table, this function will return -1.virtual void read (QDataStream & in )      ; //Reads  the item from stream in .virtual void write(QDataStream & out) const; //Writes the item to   stream out.//Returns true if the item is selected, otherwise returns false.bool  isSelected() const;void setSelected(bool select); //Sets the selected state of the item to select./*enum Qt::ItemFlag {NoItemFlags = 0,ItemIsSelectable = 1,ItemIsEditable = 2,ItemIsDragEnabled = 4,ItemIsDropEnabled = 8,ItemIsUserCheckable = 16,ItemIsEnabled = 32,ItemIsAutoTristate = 64,ItemNeverHasChildren = 128,ItemIsUserTristate = 256};Q_DECLARE_FLAGS(ItemFlags, ItemFlag)Q_DECLARE_OPERATORS_FOR_FLAGS(ItemFlags)*/inlineQt::ItemFlags        flags() const { return itemFlags; } //返回條目具有的屬性void              setFlags(Qt::ItemFlags flags);virtual QVariant     data(int role) const;               //讀寫條目里具有的數據。virtual void      setData(int role, const QVariant &value);//以下依次是讀寫條目里各角色對應的數據。inline QString       text() const         //角色 0{   return data(Qt::DisplayRole).toString(); }inline void       setText(const QString & text){   setData(Qt::DisplayRole, text); }inline QIcon         icon() const         //角色 1{   return qvariant_cast<QIcon>(data(Qt::DecorationRole)); }inline void       setIcon(const QIcon & icon){   setData(Qt::DecorationRole, icon); }inline QString       toolTip() const      //角色 3{ return data(Qt::ToolTipRole).toString(); }inline void       setToolTip(const QString & toolTip){ setData(Qt::ToolTipRole, toolTip); }inline QString       statusTip() const    //角色 4{   return data(Qt::StatusTipRole).toString(); }inline void       setStatusTip(const QString &statusTip){   setData(Qt::StatusTipRole, statusTip); }inline QString       whatsThis() const    //角色 5{   return data(Qt::WhatsThisRole).toString(); }inline void       setWhatsThis(const QString & whatsThis){   setData(Qt::WhatsThisRole, whatsThis); }inline QFont         font() const         //角色 6{   return qvariant_cast<QFont>(data(Qt::FontRole)); }inline void       setFont(const QFont & font){   setData(Qt::FontRole, font); }inline int           textAlignment() const//角色 7{   return data(Qt::TextAlignmentRole).toInt(); }inline void       setTextAlignment(int alignment){   setData(Qt::TextAlignmentRole, alignment); }inline QBrush        background() const   //角色 8{   return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); }inline void       setBackground(const QBrush & brush){   setData(Qt::BackgroundRole,brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }//QBrush(Qt::GlobalColor color, Qt::BrushStyle bs = Qt::SolidPattern);inline QBrush        foreground() const   //角色 9{   return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); }inline void       setForeground(const QBrush &brush){   setData(Qt::ForegroundRole,brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }inline  //enum Qt::CheckState { Unchecked, PartiallyChecked, Checked };Qt::CheckState       checkState() const   //角色 10{   return static_cast<Qt::CheckState>(data(Qt::CheckStateRole).toInt()); }inlinevoid              setCheckState(Qt::CheckState state){   setData(Qt::CheckStateRole, state); }inline QSize         sizeHint() const     //角色 13{   return qvariant_cast<QSize>(data(Qt::SizeHintRole)); }inline void       setSizeHint(const QSize & size){   setData(Qt::SizeHintRole, size.isValid() ? QVariant(size) : QVariant()); }}; //完結 class QTableWidgetItem#ifndef QT_NO_DATASTREAMQ_WIDGETS_EXPORT QDataStream & operator>>(QDataStream &in , QTableWidgetItem       &item);
Q_WIDGETS_EXPORT QDataStream & operator<<(QDataStream &out, const QTableWidgetItem &item);#endifclass QTableWidgetPrivate;/*
The QTableWidget class provides an item-based table view with a default model.Detailed Description :
表格小部件為應用程序提供標準的表格顯示功能。QTableWidgetltem中的項目由 QTableWidgetltem 提供。如果你想使用自己的數據模型來創建表格,你應該使用QTableView而不是這個類。表格小部件可以使用所需數量的行和列進行構建:tableWidget = new QTableWidget(12, 3, this);Alternatively, tables can be constructed without a given size and resized later:tableWidget = new QTableWidget(this);tableWidget->setRowCount(10);tableWidget->setColumnCount(5);項目在表之外創建(沒有父控件)并使用設置方法插入到表中。QTableWidgetItem * newItem = new QTableWidgetItem(tr("%1").arg((row+1)*(column+1)));tableWidget->setItem(row, column, newItem);如果您想在表格控件中啟用排序功能,詳細信息,請參閱setltem()方法.
請在填充內容后執行此操作,否則排序可能會影響插入順序.表格可以同時擁有橫向和縱向標題。創建標題的最簡單方法是向`setHorizontalHeaderLabels()和
`setVerticalHeaderLabels('函數提供一系列字符串。
這些函數將為表格的列和行提供簡單的文本標題。
更復雜的標題可以由現有的表格項生成,而這些表格項通常是在表格之外構建的。
例如,我們可以構建一個帶有圖標和對齊文本的表格項,并將其用作特定列的標題:QTableWidgetItem *cubesHeaderItem = new QTableWidgetItem(tr("Cubes"));cubesHeaderItem->setIcon(QIcon(QPixmap(":/Images/cubed.png")));cubesHeaderItem->setTextAlignment(Qt::AlignVCenter);The number of rows in the table can be found with rowCount(),
and the number of columns with columnCount().
The table can be cleared with the clear() function.
表格中的行數可以通過rowCount()找到,列數通過columncount()找到。
表格可以通過clear()函數清空。*/class Q_WIDGETS_EXPORT QTableWidget : public QTableView
{Q_OBJECT//This property holds the number of columns / rows in the table.//By default, for a table constructed without row and column counts,//  this property contains a value of 0.Q_PROPERTY(int    rowCount READ    rowCount WRITE    setRowCount)Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount)friend class QTableModel; //這是 Qt3 里的老類,已被模型視圖架構替代了。注釋文檔里這么說的。private:void setModel(QAbstractItemModel * model) override; //私有,不再被調用了。Q_DECLARE_PRIVATE(QTableWidget)Q_DISABLE_COPY(QTableWidget)Q_PRIVATE_SLOT(d_func(), void _q_sort())Q_PRIVATE_SLOT(d_func(), void _q_emitItemEntered       (const QModelIndex & index))Q_PRIVATE_SLOT(d_func(), void _q_emitItemPressed       (const QModelIndex & index))Q_PRIVATE_SLOT(d_func(), void _q_emitItemClicked       (const QModelIndex & index))Q_PRIVATE_SLOT(d_func(), void _q_emitItemDoubleClicked (const QModelIndex & index))Q_PRIVATE_SLOT(d_func(), void _q_emitItemActivated     (const QModelIndex & index))Q_PRIVATE_SLOT(d_func(), void _q_emitItemChanged       (const QModelIndex & index))Q_PRIVATE_SLOT(d_func(), void _q_emitCurrentItemChanged(const QModelIndex & previous,const QModelIndex & current))Q_PRIVATE_SLOT(d_func(), void _q_dataChanged           (const QModelIndex & topLeft,const QModelIndex & bottomRight))public://Creates a new table view with the given parent.explicitQTableWidget(                       QWidget * parent = nullptr);  //有參構造函數QTableWidget(int rows, int columns, QWidget * parent = nullptr); //有參構造函數//Creates a new table view with the given rows and columns, and with the given parent.~QTableWidget();  //析構函數//Q_PROPERTY(int    rowCount    READ    rowCount    WRITE    setRowCount)int             rowCount() const;void         setRowCount(int rows);//Q_PROPERTY(int    columnCount READ    columnCount WRITE    setColumnCount)int             columnCount() const;void         setColumnCount(int columns);/*  這是表格窗體視圖的基類表格視圖里的構建表頭的代碼方法。
class QTableView : public QAbstractItemView
{
public :QHeaderView *     horizontalHeader() const;void           setHorizontalHeader(QHeaderView * header);QHeaderView *     verticalHeader  () const;void           setVerticalHeader  (QHeaderView * header);
}
*///Returns the horizontal header item for column, column, if one has been set;//  otherwise returns nullptr.QTableWidgetItem *      horizontalHeaderItem(int column) const;void                 setHorizontalHeaderItem(int column, QTableWidgetItem * item);//Sets the horizontal header item for column column to item.//If necessary, the column count is increased to fit the item.//The previous header item (if there was one) is deleted.之前的舊標題元素會被刪除。QTableWidgetItem *  takeHorizontalHeaderItem(int column);//Removes the horizontal header item at column from the header without deleting it.QTableWidgetItem *        verticalHeaderItem(int row) const;void                   setVerticalHeaderItem(int row, QTableWidgetItem * item);QTableWidgetItem *    takeVerticalHeaderItem(int row);//Sets the vertical header labels using labels.void                   setVerticalHeaderLabels(const QStringList & labels);void                 setHorizontalHeaderLabels(const QStringList & labels);//Returns the item for the given row and column if one has been set;//  otherwise returns nullptr.QTableWidgetItem *        item(int row, int column) const;void                   setItem(int row, int column, QTableWidgetItem * item);//Sets the item for the given row and column to item.//表格接管了該項的所有權。//請注意,如果已啟用排序(參見`sortingEnabled`),且列是當前排序列,//  則該行將被移動到由`item`確定的已排序位置。//如果您想設置某一行中的多個項(例如,通過循環調用setltem()),可能需要在操作前關閉排序功能,//然后在操作后重新開啟;這樣您就可以為同一行中的所有項使用相同的行參數(即,setltem()不會移動該行)。QTableWidgetItem *    takeItem(int row, int column);//Removes the item at row and column from the table without deleting it.//Returns a list of pointers to the items contained in the data object.//If the object was not created by a QTreeWidget in the same process, the list is empty.QList<QTableWidgetItem *> items(const QMimeData * data) const;//Returns the row / column for the item.int    row(const QTableWidgetItem * item) const;int column(const QTableWidgetItem * item) const;//Returns the QModelIndex associated with the given item.條目索引與指針之間的相互轉換。QModelIndex      indexFromItem         (const QTableWidgetItem * item ) const;QTableWidgetItem *        itemFromIndex(const QModelIndex      & index) const;//Returns a pointer to the QTableWidgetItem associated with the given index.//Returns the row / Column of the current item.int                     currentRow   () const;int                     currentColumn() const;QTableWidgetItem *      currentItem  () const;void                 setCurrentItem(QTableWidgetItem * item); //以代碼的方式選擇條目。//Sets the current item to item.//Unless the selection mode is NoSelection, the item is also selected.void                 setCurrentItem(QTableWidgetItem * item,QItemSelectionModel::SelectionFlags command);void                 setCurrentCell(int row, int column);     //直接用行列下標設定條目void                 setCurrentCell(int row, int column,      //這樣更好。QItemSelectionModel::SelectionFlags command);bool    isSortingEnabled() const;       //默認,表格排序是被禁止的。void   setSortingEnabled(bool enable);  //無注釋void      sortItems(int column, Qt::SortOrder order = Qt::AscendingOrder);//Sorts all the rows in the table widget based on column and order.//按某列排序,影響的不僅僅本列,而是所有的行。整行都因為某列的排序而移動了。int visualRow   (int logicalRow   ) const; //返回邏輯索引與視覺索引的對應關系int visualColumn(int logicalColumn) const; //隱藏并不會改變視覺索引。//Returns the widget displayed in the cell in the given row and column.//Note: The table takes ownership of the widget.//測試說明,這個窗體組件,不屬于表中元素,不是先天就存在的。未設置前,是 nullptr。QWidget *       cellWidget(int row, int column) const;void         setCellWidget(int row, int column, QWidget * widget);inline    //Removes the widget set on the cell indicated by row and column.void      removeCellWidget(int row, int column){   setCellWidget(row, column, nullptr); }QList<QTableWidgetItem *>         selectedItems () const; //處理多選用這個就夠//Returns a list of all selected ranges.QList<QTableWidgetSelectionRange> selectedRanges() const;void setRangeSelected(const QTableWidgetSelectionRange & range, bool select);//Selects or deselects the range depending on select.//QModelIndex QAbstractItemView::indexAt(const QPoint & point)基類里還有這個成員函數//Returns a pointer to the item at the given point,//  or returns nullptr if point is not covered by an item in the table widget.QTableWidgetItem * itemAt(const QPoint & p) const;inlineQTableWidgetItem * itemAt(int x,     int y) const //采用了表格自己的坐標系。{   return itemAt(QPoint(x, y)); }//Returns the item at the position equivalent to QPoint(ax, ay) in the//  table widget's coordinate system,QList<QTableWidgetItem *> findItems(const QString & text, Qt::MatchFlags flags) const;//Finds items that matches the text using the given flags./*//This enum describes the type of matches that can be//  used when searching for items in a model.enum Qt::MatchFlag { //本枚舉量用于組合框的條目搜索。本枚舉量指定了搜索方式MatchExactly           = 0, //Performs QVariant-based matching.MatchContains          = 1, //The search term is contained in the item.MatchStartsWith        = 2, //The search term matches the start of the item.MatchEndsWith          = 3, //The search term matches the   end of the item.MatchRegularExpression = 4,MatchWildcard          = 5,MatchFixedString       = 8,MatchTypeMask      = 0x0F,MatchCaseSensitive = 16,    //The search is case sensitive.MatchWrap          = 32,MatchRecursive     = 64     //Searches the entire hierarchy.};Q_DECLARE_FLAGS(MatchFlags, MatchFlag)Q_DECLARE_OPERATORS_FOR_FLAGS(MatchFlags)*/const  //Returns the item prototype used by the table.QTableWidgetItem *    itemPrototype() const; //似乎在繼承 QTableWidgetltem時才用得上void               setItemPrototype(const QTableWidgetItem *item);// Sets the item prototype for the table to the specified item.//該表格小部件在需要創建新的表格項時,將使用項原型克隆函數。//例如,當用戶在空單元格中進行編輯時。這非常有用,//尤其是在您有 QTableWidgetltem 子類并且希望確保 QTableWidget 創建您的子類實例的情況下。//表格接管原型的所有權。//返回某個單元格的位置信息QRect visualItemRect(const QTableWidgetItem * item) const; //無注釋using  QAbstractItemView::isPersistentEditorOpen;/*class QAbstractItemView {bool      isPersistentEditorOpen(const QModelIndex & index) const;void    openPersistentEditor    (const QModelIndex & index);void   closePersistentEditor    (const QModelIndex & index);}*///Returns whether a persistent editor is open for item item.bool    isPersistentEditorOpen(QTableWidgetItem * item) const; //函數重載,參數類型不一樣//Starts editing the item if it is editable.void                editItem  (QTableWidgetItem * item); //打開的是普通易失編輯框void  openPersistentEditor    (QTableWidgetItem * item); //打開持久型編輯框//Opens an editor for the give item. The editor remains open after editing.void closePersistentEditor    (QTableWidgetItem * item); //只有調用本函數才可以關閉持久框//Closes the persistent editor for item.protected:bool     event(QEvent     * e    ) override;void dropEvent(QDropEvent * event) override;virtual QStringList        mimeTypes() const;virtual QMimeData   *      mimeData(const QList<QTableWidgetItem *> & items) const;virtual bool           dropMimeData(int row, int column,const QMimeData * data, Qt::DropAction action);virtual Qt::DropActions supportedDropActions() const;//Returns the drop actions supported by this view./*enum Qt::DropAction { //本枚舉類用于描述模型視圖里的拖動操作的語義:復制、剪切或超鏈接。CopyAction       = 0x   1, //Copy the data to the target.MoveAction       = 0x   2, //Move the data from the source to the target.LinkAction       = 0x   4, //Create a link from the source to the target.ActionMask       = 0x  ff,TargetMoveAction = 0x8002, //在 Windows上,當 D&D數據的所有權應被目標應用程序接管時,//即源應用程序不應刪除這些數據時,會使用此值。//在X11上,此值用于執行移動操作。Mac上不使用TargetMoveAction。IgnoreAction     = 0x   0  //Ignore the action (do nothing with the data).};Q_DECLARE_FLAGS(DropActions, DropAction)Q_DECLARE_OPERATORS_FOR_FLAGS(DropActions)*/public Q_SLOTS://Scrolls the view if necessary to ensure that the item is visible.//The hint parameter specifies more precisely where the//  item should be located after the operation.void   scrollToItem(const QTableWidgetItem * item,QAbstractItemView::ScrollHint hint = EnsureVisible);/*enum QAbstractItemView::ScrollHint {EnsureVisible   , //Scroll to ensure that the item is visible.PositionAtTop   , //Scroll to position the item at the top    of the viewport.PositionAtBottom, //Scroll to position the item at the bottom of the viewport.PositionAtCenter  //Scroll to position the item at the center of the viewport.};Q_ENUM(ScrollHint)    //滾動屏幕到條目 index處,并指明了 index條目的新的位置virtual void QAbstractItemView::scrollTo(const QModelIndex & index,ScrollHint hint = EnsureVisible) = 0;*///Inserts an empty row into the table at row.void insertRow   (int row   ); //在行 row ,列 column處插入一行或一列。void insertColumn(int column);void removeRow(int row);void removeColumn(int column); //刪除第 row行或第 column列。//Removes the column column and all its items from the table.//Removes all items in the view. This will also remove all selections and headers.//If you don't want to remove the headers, use QTableWidget::clearContents().//The table dimensions stay the same.void clear        (); //行列框架        還會保存,表頭數據沒有了,改成了123數字void clearContents(); //行列框架和表頭數據都會保存,只清除表體中的數據,置為空。//Removes all items not in the headers from the view.//This will also remove all selections. The table dimensions stay the same.Q_SIGNALS:void itemEntered(QTableWidgetItem * item);void cellEntered(int row,     int column);void itemPressed(QTableWidgetItem * item);void cellPressed(int row,     int column);void itemClicked(QTableWidgetItem * item);void cellClicked(int row,     int column);//This signal is emitted when the specified item has been activatedvoid itemActivated(QTableWidgetItem * item);void cellActivated(int row,     int column);void itemDoubleClicked(QTableWidgetItem * item);void cellDoubleClicked(int row,     int column);//This signal is emitted whenever the data of item has changed.void itemChanged(QTableWidgetItem * item); //當條目里的數據改變時,觸發本信號void cellChanged(int row,     int column);//This signal is emitted whenever the current item changes.//The previous item is the item that previously had the focus,//  current is the new current item.       //當焦點切換時觸發本信號函數。// 經測試發現,本信號函數里的 previous 形參不要使用。否則程序會閃退。void currentItemChanged(QTableWidgetItem * current, QTableWidgetItem * previous);void currentCellChanged(int  currentRow, int  currentColumn,int previousRow, int previousColumn);void itemSelectionChanged(); //當焦點選擇變化時觸發本信號,但沒有形參。//This signal is emitted whenever the selection changes.}; //完結 class QTableWidget : public QTableViewQT_END_NAMESPACE#endif // QTABLEWIDGET_H

(15)

謝謝

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/87930.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/87930.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/87930.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

SSL證書是網絡安全的一把利刃

SSL證書&#xff08;安全套接層證書&#xff0c;現普遍升級為TLS證書&#xff09;確實是網絡安全領域中一把至關重要的“利刃”&#xff0c;它在保護數據傳輸安全、建立用戶信任、防范網絡攻擊等方面發揮著不可替代的作用。以下是其核心價值與作用的詳細分析&#xff1a;一、SS…

Apache 配置文件提權的實戰思考

在 Linux 系統中&#xff0c;如果普通用戶被授予以 sudo 執行 Apache 并加載自定義配置文件的權限&#xff08;如 sudo apache2 -f /home/user/user.conf&#xff09;&#xff0c;那么該權限極可能被濫用為本地提權路徑。 雖然 Apache 默認采用了更嚴格的權限限制機制&#xff…

代碼隨想錄算法訓練營第四十四天|動態規劃part11

1143.最長公共子序列 題目鏈接&#xff1a;1143. 最長公共子序列 - 力扣&#xff08;LeetCode&#xff09; 文章講解:代碼隨想錄 思路&#xff1a; 其實就是求兩個字符串的最長公共子序列的長度 與公共子數組的區別是可以不連續 &#xff0c;順序對就可以 狀態轉移方程不一樣 …

部署mysql

# 環境: 操作系統window11 安裝了vagrant 通過vagrant部署、啟動虛擬機(centos7) # 準備安裝mysql8 # 添加 MySQL 官方 YUM 源 sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm # 安裝 MySQL Server sudo yum install -y mysql-s…

SQL分析與打印-p6spy組件

有性能消耗&#xff0c;只推薦在非生產環境下使用 SpringBoot3MybatisPlushttps://baomidou.com/guides/p6spy/ MyBatis-Plus提供了SQL分析與打印的功能&#xff0c;通過集成p6spy組件&#xff0c;可以方便地輸出SQL語句及其執行時長。本功能適用于MyBatis-Plus 3.1.0及以上版本…

FLUX.1-Kontext 高效訓練 LoRA:釋放大語言模型定制化潛能的完整指南

在人工智能領域&#xff0c;尤其是大型語言模型&#xff08;LLM&#xff09;的應用浪潮中&#xff0c;高效、低成本地定制模型行為已成為關鍵需求。LoRA&#xff08;Low-Rank Adaptation&#xff09;技術以其參數高效、資源節省的特性脫穎而出。而 FLUX.1-Kontext 作為一款創新…

群暉 DS3617xs DSM 6.1.7 解決 PhotoStation 安裝失敗問題 PHP7.0

群暉 DS3617xs DSM 6.1.7 解決 PhotoStation 安裝失敗問題 PHP7.0問題描述解決方案1. 準備所需文件2. 檢查當前 PHP 版本3. 安裝 PHP 版本5. 查詢已安裝好的套件6. 升級 PHP 版本7. 手動安裝套件PhotoStation注意事項總結問題描述 在群暉 DS3617xs DSM 6.1.7-15284 版本中&…

pnpm 升級

pnpm 的安裝源太多了&#xff0c;感覺系統變量都有引入順序。 今天踩坑記錄&#xff1a; pnpm &#xff0c;如果最初用npm 裝的&#xff0c;可以用npm 升級&#xff1b; 如果最初用brew 裝的&#xff0c;得用brew 升級&#xff1b; 如果最初是用corepack 裝的得用corepack 升級…

[C#] WPF - 資源URI

一、組成 1、資源URI總共包括4個部分(當前程序集可以省略前3個)&#xff1a; ①&#xff1a;pack://application:,,, ②&#xff1a;/[程序集名稱] ③&#xff1a;;Component ④&#xff1a;/[資源路徑] 二、舉例 項目結構如下圖所示&#xff1a; 1、MainWindow.xaml 文件…

【Mysql系列】Mysql 多級隔離級別揭秘

目錄 一、什么是隔離級別 1.1、為什么復合操作需要事務&#xff1f; 1.2、事務的 ACID 特性如何保障操作可靠性&#xff1f; 1.3、隔離性通過隔離級別來控制 二、為什么用多級隔離級別 2.1、事務并發執行時可能引發以下問題 2.1.1、臟讀&#xff08;Dirty Read&#xff…

odoo17 警示: selection attribute will be ignored as the field is related

在 Odoo 17 中&#xff0c;當使用 related 字段時&#xff0c;直接在 fields.Selection 中指定選擇列表會被忽略&#xff08;因為選擇項會從關聯字段繼承&#xff09;。wtd_fuwlx fields.Selection(服務類型 , relatedwtd_id.fuwlx, storeTrue)遇到了一個警告&#xff0c;提示…

gemma-3n-E2B多模態模型使用案例:支持文本、圖像、語音輸入

參考&#xff1a; https://developers.googleblog.com/en/introducing-gemma-3n-developer-guide/下載&#xff1a; https://modelscope.cn/models/google/gemma-3n-E2B-it 模型下載 運行代碼&#xff1a; https://github.com/huggingface/huggingface-gemma-recipes 微調&…

計算機網絡實驗——互聯網安全實驗

實驗1. OSPF路由項欺騙攻擊和防御實驗一、實驗目的驗證路由器OSPF配置過程。驗證OSPF建立動態路由項過程。驗證OSPF路由項欺騙攻擊過程。驗證OSPF源端鑒別功能的配置過程。驗證OSPF防路由項欺騙攻擊功能的實現過程。二、實驗任務使用自己的語言簡述該實驗原理。如圖1所示的網絡…

Pytorch中torch.where()函數詳解和實戰示例

torch.where() 是 PyTorch 中非常常用的一個函數&#xff0c;功能類似于 NumPy 的 where&#xff0c;用于條件篩選或三元選擇操作。在深度學習訓練、掩碼操作、損失函數處理等場景中非常常見。一、基本語法 torch.where(condition, x, y)condition&#xff1a;一個布爾張量&…

基于Hadoop的公共自行車數據分布式存儲和計算平臺的設計與實現

文章目錄 有需要本項目的代碼或文檔以及全部資源&#xff0c;或者部署調試可以私信博主項目介紹&#xff1a;基于Hadoop的公共自行車數據分布式存儲與計算平臺設計與實現數據介紹數據預處理 Hadoop 集群的幾個主要節點介紹1. NameNode&#xff08;主節點&#xff09;2. DataNod…

Java項目:基于SSM框架實現的程序設計課程可視化教學系統【ssm+B/S架構+源碼+數據庫+畢業論文】

摘 要 使用舊方法對程序設計課程可視化教學信息進行系統化管理已經不再讓人們信賴了&#xff0c;把現在的網絡信息技術運用在程序設計課程可視化教學信息的管理上面可以解決許多信息管理上面的難題&#xff0c;比如處理數據時間很長&#xff0c;數據存在錯誤不能及時糾正等問題…

Unity 實現 NPC 隨機漫游行為的完整指南

在游戲開發中&#xff0c;NPC&#xff08;非玩家角色&#xff09;的行為邏輯對于營造真實、沉浸式的游戲世界至關重要。一個常見但又極具表現力的需求是&#xff1a;讓 NPC 在場景中自然地隨機移動&#xff0c;仿佛它們有自己的意識和目的地。 本文將詳細介紹如何使用 Unity 的…

重新學習Vue中的按鍵監聽和鼠標監聽

文章目錄按鍵事件1. 使用 keyup.enter 修飾符2. 使用 v-on 監聽鍵盤事件3. 在組件上監聽原生事件Vue 2Vue 34. 全局監聽鍵盤事件注意事項鼠標事件1. 基本鼠標事件監聽常用鼠標事件2. 事件修飾符3. 鼠標按鍵檢測4. 鼠標位置信息5. 自定義指令監聽鼠標事件6. 組合鼠標事件7. 性能…

vue2啟動問題以及解決方案

vue2啟動時&#xff1a;ERROR Invalid options in vue.config.js: "typescript.validate.enable" is not allowed如果需要在 VSCode 中控制 TypeScript 驗證&#xff1a;在項目根目錄創建 .vscode/settings.json 文件&#xff08;如不存在&#xff09;添加以下配置&a…

Vue響應式系統:從原理到核心API全解析

響應式原理 響應式機制的主要功能就是&#xff0c;可以把普通的JavaScript對象封裝成為響應式對象&#xff0c;攔截數據的讀取和設置操作&#xff0c;實現依賴數據的自動化更新。 Q: 如何才能讓JavaScript對象變成響應式對象&#xff1f; 首先需要認識響應式數據和副作用函數…