Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] QTableView and edit mode
Forum Updated to NodeBB v4.3 + New Features

[solved] QTableView and edit mode

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 5.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dmcr
    wrote on last edited by
    #1

    Hello,

    I have implemented a very simple Widget, let say
    @W::W(QAbstractItemModel * model)
    {

    *tv = new QTableView(this);
    tv.setModel(model); // case 1

    //setModel(model); // case 2
    }
    @
    and @class W : public QTableView
    {
    Q_OBJECT
    public:
    explicit W(QAbstractItemModel * model);

    QTableView * tv;
    }@
    actually in the case 1, the table is editable, in the second not.
    Can someone explain me what is the distinction between both ?

    dmcr

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      You can use "setEditTriggers(QAbstractItemView::AllEditTriggers)":http://qt-project.org/doc/qt-5.0/qtwidgets/qabstractitemview.html#editTriggers-prop for your tableView

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dmcr
        wrote on last edited by
        #3

        H!i,

        Thanks for your reply.
        In fact when i use setEditTriggers(QAbstractItemView::DoubleClicked); it does not work as i would like ;
        and when i use setEditTriggers(QAbstractItemView::DoubleClicked) neither.
        However i don't see any real difference between the two cases showed in the first post, that's why ia am asking the question also.

        dmcr

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sam
          wrote on last edited by
          #4

          Ok one simple question since W inherits from QTableView then what is the need of having another table TV initialized inside class W .

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            [quote author="dmcr" date="1370260449"]
            However i don't see any real difference between the two cases showed in the first post, that's why ia am asking the question also.[/quote]
            There is no semantic difference between those 2 cases (regarding the usage of setModel()). You must be doing something else after the constructor is called which prevents the second case to work as expected.
            Since case 1 works for you (which lets me assume that you don't set the model on itself) you maybe set another model afterwards which is not editable?

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dmcr
              wrote on last edited by
              #6

              bq. There is no semantic difference between those 2 cases

              Yes that's what i intend to explain.
              Actually i had some mousePressEvent, whitch was changing th behaviour.

              dmcr

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved