Dear all,
I'm using a commercial library that I cannot modify. There's this one
class in the library which is almost 90% usable. But unfortunately, I
have to reimplement 3 member functions. The problem is the original
class is not designed very well, because it is assumed to be the final
class. Because I have to modify some private members in the
reimplemented functions. What should I do? Design a new class or doing
something else?
Here is the detailed information:
I have to design a Label class which can show both bitmap and text.
I'm using QT as my base library. QT has a class named QLabel, but it
only supports either bitmap or text. QLabel has two virtual functions,
one is setText, and another is setPixmap, but they eliminate the other
one when being called. So I have to reimplement the two functions. But
the problem is the text and bitmap members are private in QT, and
there's no other functions to set the values other than setText and
setPixmap. So what should I do? Simply copy the code and design a new
class according to QLabel or else?
Thanks in advance!
Jack 3 1554
"Jack" <zh******@263.net> wrote in message
news:b8**************************@posting.google.c om...
.... I have to design a Label class which can show both bitmap and text. I'm using QT as my base library. QT has a class named QLabel, but it only supports either bitmap or text. QLabel has two virtual functions, one is setText, and another is setPixmap, but they eliminate the other one when being called. So I have to reimplement the two functions. But the problem is the text and bitmap members are private in QT, and there's no other functions to set the values other than setText and setPixmap. So what should I do? Simply copy the code and design a new class according to QLabel or else?
I would recommend replicating the code and making your own parallel
implementation.
This is probably the least likely to 'break' with later versions of your
library, and will give you more freedom if you later need to make additional
changes (e.g. controlling the relative placement of the text and image).
hth -Ivan
-- http://ivan.vecerina.com/contact/?subject=NG_POST <- e-mail contact form
In article <b8**************************@posting.google.com >, zh******@263.net (Jack) wrote: Dear all,
I'm using a commercial library that I cannot modify. There's this one class in the library which is almost 90% usable. But unfortunately, I have to reimplement 3 member functions. The problem is the original class is not designed very well, because it is assumed to be the final class. Because I have to modify some private members in the reimplemented functions. What should I do? Design a new class or doing something else?
Here is the detailed information: I have to design a Label class which can show both bitmap and text. I'm using QT as my base library. QT has a class named QLabel, but it only supports either bitmap or text. QLabel has two virtual functions, one is setText, and another is setPixmap, but they eliminate the other one when being called. So I have to reimplement the two functions. But the problem is the text and bitmap members are private in QT, and there's no other functions to set the values other than setText and setPixmap. So what should I do? Simply copy the code and design a new class according to QLabel or else?
I would use two QLabel objects. Put them both in a single class that is
in charge of making sure they are properly positioned relitive to each
other. zh******@263.net (Jack) wrote in message news:<b8**************************@posting.google. com>... Dear all,
I'm using a commercial library that I cannot modify. There's this one class in the library which is almost 90% usable. But unfortunately, I have to reimplement 3 member functions. The problem is the original class is not designed very well, because it is assumed to be the final class. Because I have to modify some private members in the reimplemented functions. What should I do? Design a new class or doing something else?
Here is the detailed information: I have to design a Label class which can show both bitmap and text. I'm using QT as my base library. QT has a class named QLabel, but it only supports either bitmap or text. QLabel has two virtual functions, one is setText, and another is setPixmap, but they eliminate the other one when being called. So I have to reimplement the two functions. But the problem is the text and bitmap members are private in QT, and there's no other functions to set the values other than setText and setPixmap. So what should I do? Simply copy the code and design a new class according to QLabel or else?
Thanks in advance! Jack
Though this is a bit off-topic:
Create your own widget (derived from QWidget or QFrame (*)) and give it
2 members QLabel: one carrying the bitmap and one carrying the text.
Create a nice, small custom widget and register is designer.
(*) depends if you need signals or not.
Stephan Brönnimann br****@osb-systems.com
Open source rating and billing engine for communication networks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: George Sakkis |
last post by:
I'm looking for a design to a problem I came across, which goes like
this (no, it's not homework):
1. There is a (single inheritance) hierarchy of domain classes, say
A<-B<-..<-Z (arrows point...
|
by: Gert Van den Eynde |
last post by:
Hi all,
I have a question on interface design: I have a set of objects that are
interlinked in the real world: object of class A needs for example for the
operator() an object of class B. On...
|
by: Merlin |
last post by:
Hi
Imagine the following classes (A class diagram will help)
BASE, A, B, C, D, E, F, G.
A, B, C, D, G inherit from BASE.
E, F inherit from D.
|
by: JKJ |
last post by:
I'm not an OOP guru, but I would say ". . .not necessarily"
What if the base class and derived classes are internal?
Then the base class has to be within the same assembly to
be inherited from. ...
|
by: Mark O'Flynn |
last post by:
I would like some advice regarding implementing inheritance using vb.net.
I have an application written in vb6 that I am rewritting from the ground up
in vb.net to take full advantage of .net,...
|
by: Brad Pears |
last post by:
I am completely new to vb .net. I am using visual Studio 2005 to redo an
Access 2000 application into a .net OO application using SQL Server 2000 -
so a complete rewrite and re-thinking of how...
|
by: nw |
last post by:
Hi,
I was wondering if someone would be able to give me some comments on
the following class structure, it feels to me as if there must be a
better way, but I'm unsure what it is, perhaps I...
|
by: snewman18 |
last post by:
In learning about design patterns, I've seen discussion about using
inheritance when an object's relationship to another object is 'is-a'
and composition when the relationship is 'has-a'.
Since...
|
by: Immortal Nephi |
last post by:
I have an idea how to design an object in a better way. I would like
to give you
my thought example. Please let me know what you think if it is best
object design.
Please recommend me any book...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |