Results 1 to 2 of 2

Thread: What is the best way to subclass and replace widgets from gui?

  1. #1
    Join Date
    Nov 2010
    Posts
    31
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default What is the best way to subclass and replace widgets from gui?

    Hi

    Sometimes, or quite often, I need some extra functionality from items like QGraphicsView, QPushButton, etc, so I need to subclass them and add my functions, but this items are already in their places in gui because in QtDesigner I created them, I had do that because I want to know how interface will look like. So now, during application start I create my own object like "MyGraphicsView, public QGraphicsView", then I delete original QGraphicsView object created in ui_mainwindow.h and I place my object in the layout cell where the QtDesigner originally placed it. It work's for me, but frankly saying it's cumbersome and I'm not sure if it's right approach? Is there a better way to subclass items from gui? I know I could not to create this QGraphicsView in QtDesigner in the first place, but then working with gui interface in QtDesigner where there are blind spots instead of items is also cumbersome.

    best regards
    Marek

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: What is the best way to subclass and replace widgets from gui?

    You can promote widgets.

  3. The following user says thank you to Zlatomir for this useful post:

    franki (21st May 2012)

Similar Threads

  1. Replace widget on tab
    By wirasto in forum Qt Programming
    Replies: 1
    Last Post: 14th August 2010, 14:01
  2. Replies: 8
    Last Post: 12th February 2010, 02:41
  3. Replace keyPressEvent (dot with tab)
    By the_bis in forum Qt Programming
    Replies: 1
    Last Post: 6th June 2008, 10:43
  4. How do I replace a widget?
    By pir in forum Qt Programming
    Replies: 4
    Last Post: 24th July 2006, 16:51

Tags for this Thread

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.