Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. qheaderview
    Log in to post

    • UNSOLVED One QHeaderView for multiple view
      General and Desktop • qtableview qheaderview • • dridk2  

      2
      0
      Votes
      2
      Posts
      50
      Views

      QHeaderView is a widget. You can't have one widget in two places at the same time. You can have two header views and sync them on change.
    • UNSOLVED QTreeView setRootIndex & changing header - incorrect columnCount...?
      General and Desktop • qtreeview qheaderview • • Dariusz  

      6
      0
      Votes
      6
      Posts
      355
      Views

      I'm using abstractItemModel / my own item, I ensure that columnCount return correct number of columns, yet it's still wrong. In regard to using proxyModels, I'd love to use it, but I only found few examples and I'm struggling as to how I would do it. Any hints wold be great, I would prefer to use a proxy instead here. I literally have no idea how I can simulate setRootIndex with proxyModel, since I need to see parentItem of the item that I wish to set as rootitem and I don't want to see these parent items... here was me early attempt > https://forum.qt.io/topic/102227/qsortfilterproxymodel-simulate-new-root-index/2 @Christian-Ehrlicher I'm totally blaming you for me going this setRootIndex road as I was trying proxy early and you said to use this : p
    • SOLVED Forward declaration error inside include qtableview.h
      General and Desktop • qheaderview qt sources building error declaration forward • • smillmorel  

      4
      0
      Votes
      4
      Posts
      531
      Views

      @smillmorel said in Forward declaration error inside include qtableview.h: Don't really know what happended there, but it did work. There is no magic to it. Some Qt classes only forward declare the classes they use internally. If you use them in your code, you need to include them on your side.
    • UNSOLVED Default sort indicator order in QHeaderView
      General and Desktop • qtableview qheaderview sorting • • MrBolton  

      7
      1
      Votes
      7
      Posts
      2714
      Views

      I know the topic is quite old, but I experienced the exact same issue and this thread was popping up in my search. So, adding a QSortFilterProxyModel and enabling sorting with setSortingEnabled(true) sorts the table in descending order. I got the correct order when I explicitly specifying the order via indicator right before enabling the sort: table->horizontalHeader()->setSortIndicator(0, Qt::AscendingOrder); table->setSortingEnabled(true);
    • SOLVED How do I detect which column was clicked in a QTableview header
      General and Desktop • qtableview qheaderview column clicked • • mmikeinsantarosa  

      8
      0
      Votes
      8
      Posts
      5556
      Views

      @mmikeinsantarosa Hi just to be clear You do not name the parameter when using a function in a connect. Nor for signal OR the slot. So if you function is like void MySlot( int ID, QString Name) ( in .h and cpp) you would only use as MySlot( int, QString) for connect.
    • Can't hide QTableView column after 'resetting' the QAbstractTableModel [Qt 5.5.1]
      General and Desktop • qtableview qheaderview hide column hidecolumn • • Phil_W  

      4
      0
      Votes
      4
      Posts
      1484
      Views

      Glad you found a solution ! Can you share a small sample code that triggers this behaviour ?
    • SOLVED CSS + QTableView/QHeaderView: font-weight ignored?
      General and Desktop • qtableview stylesheet qheaderview • • the_  

      3
      0
      Votes
      3
      Posts
      2478
      Views

      @raven-worx Hi, thanks for your reply and information. Will mark it as "solved", as it is only a minor but interesting styling "issue" :)
    • SOLVED Always display the visual index number of a QHeaderView after sorting
      General and Desktop • qtableview qheaderview • • panosk  

      5
      0
      Votes
      5
      Posts
      2313
      Views

      @thEClaw Well, since you were worried about how clean your solution was, I thought I should come up with a nastier hack: -): I'm storing the ints in my map as negative numbers and then I retrieve the "real" numbers in the model's data() method like this: ... if (item.column() == 2) { int fake = recordsMap.keys().at(item.row()); return abs(fake); } ... At least everything works and displays fine now. I fiddled a lot with visualIndex() and logicalIndex() but couldn't find a way to make this work, so I'm keeping this for the time being. Thanks anyway for your suggestion!
    • UNSOLVED Hierarchical Header View
      General and Desktop • qtableview qheaderview • • skebanga  

      2
      0
      Votes
      2
      Posts
      3852
      Views

      Further investigation into the issue has revealed that HiearchicalHeaderView re-implements the header views sections, and there is no relationship between the QHeaderView notion of sections, and the HiearchicalHeaderView notion of sections. As a result, the following calls are available, but return incorrect data. QHeaderView::count() returns 0 QHeaderView::sectionSize(int) returns 0 QHeaderView::logicalIndex(int) returns -1 etc... The upshot of this is that there is a significant amount of work required in HierarchicalHeaderView in order to make in feature complete, and that the way it is currently implemented is not symbiotic with QHeaderView That essentially leaves 2 questions. Does an open source feature-complete hierarchical header view exist? Is there a way to easily implement hierarchical headers in a QHeaderView?
    • UNSOLVED Set minimum column width to QTableView.
      General and Desktop • qtableview model-view mvc qheaderview • • tokafr  

      5
      0
      Votes
      5
      Posts
      14592
      Views

      Hi, You can try with the QHeaderView::minimumSectionSize property
    • UNSOLVED What is QHeaderView default delegate.
      General and Desktop • qtableview delegate qheaderview • • tokafr  

      2
      0
      Votes
      2
      Posts
      997
      Views

      HI, No it's not. You have the explanation here
    • UNSOLVED Remove border lines from QHeaderView.
      General and Desktop • qtableview mvc qheaderview qframe • • tokafr  

      1
      0
      Votes
      1
      Posts
      646
      Views

      No one has replied

    • UNSOLVED How to use QHeaderView in QScrollArea?
      General and Desktop • qheaderview • • AlaaM  

      2
      0
      Votes
      2
      Posts
      910
      Views

      @AlaaM Hello, How do I get it to be fixed? Maybe it needs to not be a part of the scrollarea? This would be my choice, yes. I'd put the header and the scroll area in a vertical layout (setting the stretches to 0 for the header and 1 for the scroll area) and take it from there. Kind regards.
    • UNSOLVED QHeaderView mouse tracking fails
      General and Desktop • qheaderview qmouseevent • • Vagabond  

      4
      0
      Votes
      4
      Posts
      1145
      Views

      You're welcome ! You can also check in your profile settings whether the email notification is active. Since you have it working now, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)
    • SOLVED Update QHeaderView section count to reflect changes in the model
      General and Desktop • qtreeview qheaderview • • skebanga  

      14
      0
      Votes
      14
      Posts
      5339
      Views

      Technically the "last number of columns" is rather a model specific data. Since that part can change, the model should check the last value and then emit the signal accordingly. The section ordering part, on the other hand, is indeed view specific data and the model shouldn't do anything with them.
    • SOLVED How to add Icon into QHeaderView
      General and Desktop • qtableview qheaderview • • karlheinzreichel  

      2
      0
      Votes
      2
      Posts
      3528
      Views

      Got a solution for that question by myself. The solution works also for right aligned text. void MyHeaderView::paintSection(QPainter* painter, const QRect& rect, int logicalIndex) const { // The Icon to draw on right of the header text is in iconPixmap QRect iconRect = iconPixmap.rect(); QRect textRect = rect; textRect.setWidth(textRect.width() - iconRect.width()); QFont myFont = getFont(); // delivers the font for for the header text QFontMetrics fontMetrics(myFont); // determine the elided text which will be printed for the available width // m_header_padding is the padding of the headerview section QString elidedText = fontMetrics.elidedText(text, Qt::ElideRight, textRect.width() - m_header_padding * 2); // Drawing procedure // First draw without text over the complete header section size // this will draw the background and the borders etc. for the complete header section model() -> setHorizontalHeaderText(index, QString()); // set text in model without emitting datachanged QHeaderView::paintSection(painter, rect, logicalIndex); // now draw the (possibly elided) text into the header section model() -> setHorizontalHeaderText(logicalIndex, elidedText); QHeaderView::paintSection(painter, textRect, logicalIndex); // Now restore the header section text in the model model() -> setHorizontalHeaderText(logicalIndex, text); // Draw the icon // center icon vertical int iconHeight = iconRect.height(); int headerHeight = rect.height(); int offset = 0; if (iconHeight < headerHeight) { offset = (headerHeight - iconHeight) / 2; } painter -> setClipRect(rect); painter -> drawPixmap(textRect.right()-1, rect.top() + offset, iconRect.width(), iconRect.height(), iconPixmap); painter -> setClipRect(rect); }
    • SOLVED How To Add Select All Checkbox in QTableWidget QHeaderView
      General and Desktop • qtablewidget qheaderview checkbox select all • • maximo  

      3
      0
      Votes
      3
      Posts
      9383
      Views

      @maximo Hi It creates a new Header that draws a check box image on itself since its not possible to insert a real widget. It then response to mouse press to make the image work as a real check box. it checks with if (logicalIndex == 0) so I think it only paints this in first column.
    • How to make vertical header of QTableWidget resizable by mouse?
      General and Desktop • qtablewidget qheaderview • • asmirn  

      10
      0
      Votes
      10
      Posts
      4650
      Views

      Hi asmirn I think I have a solution regarding your question. You have to implement the resize mechanism by yourself as the QTableView / QHeaderView will not support the resizing by itself. The way i did: First derive a subclass from QHeaderView (e.g. VerticalHeaderView) and override the mousePressEvent / mouseMoveEvent / mouseReleaseEvent, to get the relevant mouseclicks mousemove-positions for the headerview. Then if the user clicks the left mouse button in a certain distance to the left VerticalHeaderView border you can start resizing the VerticalHeaderView with setFixedWidth(newWidth). Do not forget to tell the according QTableView/QTableWidget about the resizing by calling updateGeometries() for the QTableView/QTableWidget.
    • [Solved] Subclass QHeaderView.
      General and Desktop • qtableview qheaderview subclassing inheritance • • SwePtr  

      3
      0
      Votes
      3
      Posts
      1942
      Views

      Oh, I see. Thank you sir.
    • Add combobox in Header View
      General and Desktop • qtableview qtablewidget delegate qheaderview • • navap  

      3
      0
      Votes
      3
      Posts
      2288
      Views

      @SGaist Hi SGaist! Thanks for reply! I had tried this and it will result in static controls being placed on header. Upon Horizontal scroll to right/left, it will appear immovable. Thanks for the info though!
    • synchronize two QabstractItemModel on Single Common Column
      General and Desktop • qwidget qtableview qabstractitemmo qheaderview qwindow sorting custom item • • Zee_07  

      1
      0
      Votes
      1
      Posts
      493
      Views

      No one has replied