c++ - Qt: TableWidget's ItemAt() acting weirdly -


I am working on a Windows application, where in a dialog I ask for some data from postgres and manually output To show me A table widget.

  m_ui-> Table Widget-> Settokount (connected datatown ()); Each line {m_ui-> TableWidget- & gt; ITunes (); i ++); //; M_ui- for setItem (i, 0, new QTableWidgetItem (for data [i] .bobin.referenceNumber) (int i = 0; i & lt; Gt; Tableview-> Set item (i, 1, new QTableWidgetItem (QString :: number (associated data [i] .bobin.width)); M_ui- & gt; Table-Widget- & gt; set item ( I, 2, new QTableWidgetItem (QString :: number (linked data). Tolerance.getHole ()))); M_ui-> Tableview-> Set item (i, 3, new QTableWidgetItem (QString :: number (linked data). Tolerance.getLessThanZeroFive ()))); M_ui-> Tableview-> Set item (i, 4, new QTableWidgetItem (QString :: number (linked data). Tolerance.getZeroFive_to_zeroSeven ()))); M_ui-> Table Widget-> SetItem (i, 5, new QTableWidgetItem (QString :: number (linked data). Tolerance.getZeroFive_to_zeroSeven_repetitive ()))); M_ui-> Tableview-> Set item (i, 6, new QTableWidgetItem (QString :: number (linked data). Tolerance.getZeroSeven_to_Three ()))); M_ui-> Tableview-> Set item (i, 7, new QTableWidgetItem (QString :: number (linked data). Tolerance.getThree_to_five ()))); M_ui-> Tableview-> Set item (i, 8, new QTableWidgetItem (QString :: number (linked data). Tolerance.getMoreThanFive ()))); }  

Also, based on the information of the row and column, I paint some of these tableswitaitimes in some colors, but I do not think it is relevant.

QContextMenuEvent * Event) {QMenu Menu (m_ui-> TableWidget); // Standard Actions menu.Adaction (this-> MarkineActive Action); Menu.addAction (this-> MarkActiveAction); Menu.addSeparator (); Menu.addAction (this-> ExportAction); Menu.addAction (this-> ExportAllAction); // Get rightClickAytimateQTableWidgetItem * clickedItem = m_ui- & gt; Table Widget-> On items (m_ui- & gt; Table-> Widget-> Map FromGlobal (event- & gt; Global Peace ()); // If it is colorful, then add some more actions (clicked etam amp; clicked-> columns ()> gt; 1 & amp; amp; amp; amp; clicked items-> line ()> {//} This is the property, I am keeping it for later use-> LastRightClickedItem = clickedItem; // Debug Objective: QMessageBox :: Notification (this, "", Caststring ("Clicked item =% 1,% 2"). Arg (clicked item-> line ()). Arg (clickedItem-> ; Column ())); QMessageBox :: Notification (This, "", Caststring ("GlobalClick =% 1,% 2 \ n Transformed Piece =% 3,% 4") Arg (event- & gt; Global X.) Arg (event- & Gt; globalY ()) .arg (m_ui-> TableWidgett-> Mapfram Global (Event-> Global Peace ()). (()). Arg (m_ui-> TableWidgett-> Mapfram Global ( Event- & gt; Global Peace ()). Y ()); menu.addSeparator (); menu.addAction (this-> changeSelectedToleranceToUygun); menu.addAction (this-> changeSelectedToleranceToUyar); menu.addAction (This-> changeSelectedToleranceToDurdurUyar); // Some other irreversible 'enable / disable' activities menu.exec (event-> globalPos ());}

The problem is, when I right click on the same item, I get the same global coordinates, but randomly different row-column information. For example, the global status is actually 600,230 But the row-column pair is randomly (5,3) and (4,3). I mean, what ?!

In addition, when I have been in the previous rows (for more than 13 times) , I think) I click on an object, never in the condition Will come "if (clicked Itm & amp; Clicked items-> Columns ()> 1 & amp; Amp; Amp; Clicks> ITEM-> Line ()> 0) ", I think this is mainly because 'clickedItem' is zero.

I would be happy to share more information, or even Thank you very much for getting full CPP-HI trio help.

Try it:

  QTableWidgetItem * clickedItem = m_ui- & gt; Table-Widget-> itemAt (event-> pos ());  

The problem is that without considering the scrollable area, In order to map the global position in any situation, you can go to itemAt , tableWidget-> viewport () -> gt ; MapFromGlobal .


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -