Results 1 to 7 of 7

Thread: QTablewidget: how to select row with single click instead of double click?

  1. #1
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default QTablewidget: how to select row with single click instead of double click?

    Hello,

    I have QTableWidget in my UI, but I have a problem, because I cannot select a row with single click, but only with double click (selectionBehavior is selectRows). I tried with cellClicked(int, int) signal, but with no success. How can I solve that?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTablewidget: how to select row with single click instead of double click?

    Please provide a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTablewidget: how to select row with single click instead of double click?

    If you are talking about editing the item on single click, instead of double click, then have a look at QAbstractItemView::setEditTriggersOtherwise, the row or cell should be selectable on single click only.

  4. #4
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTablewidget: how to select row with single click instead of double click?

    Hm, I use Qt Creator to build a program. I use QTableWidget, cells are filled with QLabel (setCellWidget). Maybe I have a problem because single click is intercepted by that QLabels that reside inside table cells? How can I connect these signals, so that qtablewidget receives them?

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTablewidget: how to select row with single click instead of double click?

    Why are you using QLabel Is there some extra rendering with the label ?
    I dont see much use of using QLabel as a cell Widget... you could always use delegates to render simple text in a different way

  6. #6
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTablewidget: how to select row with single click instead of double click?

    I use QLabel because I use some HTML formatted text and/or images inside cells, so I think that QLabels are natural choice, or am I missing something?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTablewidget: how to select row with single click instead of double click?

    Yes, you are missing something. We don't use widgets inside ItemViews, at least we try not to. Your widget is not part of the model nor part of the view thus all the functionality of ItemViews will not work with it. Search the forum for an implementation of a delegate rendering a QTextDocument.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Double Click Capturing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2011, 14:12
  2. Replies: 2
    Last Post: 11th January 2009, 23:24
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. QGraphicsScene Click / Double Click
    By philentropist in forum Qt Programming
    Replies: 1
    Last Post: 9th February 2007, 04:32
  5. Replies: 5
    Last Post: 12th January 2006, 15:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.