PDA

View Full Version : Is there a QT widget similar to the Task Panel's used in many XP applications.



gsQT4
12th August 2006, 00:09
I'm writing an application using QT 4.1. I'm designing the UI to have a look and feel similar to other UI's used in applications designed for Windows XP. I would like to have a task panel, which will lists the tasks available to the user. Is there a widget like this for QT 4.1, that will work in Windows and Linux? The url below will take you to a site that can show you what I'm looking for. Thanks.

http://www.codejock.com/products/taskpanel/

Brandybuck
12th August 2006, 00:57
Once upon a time, in a land far far away, we used call these things "context menus". Is there any reason you can't use a QMenu context menu?

jpn
12th August 2006, 09:15
As far as I remember, Qt's "toolbox" aka QToolBox allows only one "tab" to be expanded at time. So presumably it's not what you're after. A QTreeView however, could be customized to achieve the both, look 'n feel & functionality.

Brandybuck
12th August 2006, 23:16
I guess I'm confused as to what is wanted. I thought he was referring to the task menu shown on his link.

Chicken Blood Machine
14th August 2006, 08:06
It's not a menu, just a list of options tht is collapsible.

I came across this (some time ago for Qt3) http://www.vcreatelogic.com/oss/qpulistview/index.html

Seems to be just what you are looking for. Maybe you can rewrite it for Qt4?

gsQT4
16th August 2006, 00:23
Thanks for the reply Chicken Blood Machine. I've downloaded the source code for this widget and am attempting to port it from QT3 to QT4. I've run into several errors with that process, so I'm trying to resolve them.

Thanks again.

Chicken Blood Machine
16th August 2006, 03:19
Cool. Be sure to post if you need any help.

gsQT4
16th August 2006, 13:25
Well, I decided to try it out in QT3 to make sure it does what I need it to do. But, I cannot seem to be able to get it to compile. I've attached a simple program that I'm triess to use the widget. I don't suppose you've used this widget before?

Thanks,
Glenn

Chicken Blood Machine
16th August 2006, 17:49
I'm not in a position to compile your code right now, but it looks like you're passing a char to the QpuListView constructor when you should be passing a char*. What is the compile error that you are getting?

gsQT4
16th August 2006, 18:24
Sorry I did not include the error messages. There were many errors last night. Using g++, it keeps referring to an undefined reference to that constructor.

I noticed when I looked at it again later this morning, that I was passing a Character and not a pointer. Guess I was up too late fighting with this thing. It's been awhile since I've used my limited C++ skills. :o I made some changes and will try compiling the revised code tonight.

Thanks.

gsQT4
17th August 2006, 04:28
Well, the problem appears to be with the linker. The file itself will compile. If I switch out QpuListView for the regular QListView, it works fine. I compiled the widget as a shared library without errror. I placed the libraries in $QTDIR/lib and the header in $QTDIR/include.

Below is the compiler messages:

cd '/home/glenns/projects/tst' && QTDIR="/usr/lib/qt3" gmake -k clean && QTDIR="/usr/lib/qt3" gmake -k
rm -f tst.o
rm -f *~ core *.core
g++ -c -pipe -Wall -W -g -DQT_SHARED -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -I/usr/lib/qt3/mkspecs/default -I. -I. -I/usr/lib/qt3/include -o tst.o tst.cpp
tst.cpp: In function 'int main(int, char**)':
tst.cpp:17: warning: unused variable 'quit'
tst.cpp:27: warning: unused variable 'items'
g++ -o tst tst.o -L/usr/lib/qt3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
tst.o: In function `main':
/home/glenns/projects/tst/tst.cpp:25: undefined reference to `QpuListView::QpuListView(QWidget*, char const*)'
/home/glenns/projects/tst/tst.cpp:27: undefined reference to `QpuListViewItem::QpuListViewItem(QpuListView*, QString const&)'
collect2: ld returned 1 exit status
gmake: *** [tst] Error 1
gmake: Target `first' not remade because of errors.
*** Exited with status: 2 ***

Here is the file I'm trying to compile:

#include <qapplication.h>
#include <qfont.h>
#include <qpushbutton.h>
#include <QpuListView.h>
#include <qgrid.h>

int main(int argc, char *argv[])
{
char *Q = new char(0) ;

QApplication app(argc, argv);

// QPushButton *quit = new QPushButton("Quit", 0);
// quit -> resize(75, 30);
// quit -> setFont(QFont("Times", 18, QFont::Bold));

// QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));

QGrid *container = new QGrid( 1 );

QpuListView *listview = new QpuListView( container, Q ) ;

QpuListViewItem *items = new QpuListViewItem( listview, "Test" );

// QpuWidgetItem widgets = new QpuWidgetItem(items, quit ) ;

container -> show();

return app.exec();

delete container ;
delete Q ;
delete listview ;

return 0;

}

Chicken Blood Machine
17th August 2006, 05:18
-L/usr/lib/qt3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm

I don't see any reference to the library that you compiled. What is it called? You should have something like:

-L/usr/lib/qt3/lib -L/usr/X11R6/lib -lQpu -lqt-mt -lXext -lX11 -lm

Also, it's not really appropriate to put any library that you build in $QTDIR/lib. You should put it in a user-defined place and make sure that it is on your linker path (with -L). If it is a shared lib, you also have to make sure it is on the LD_LIBRARY_PATH when you run the program.

BTW, for this test, you don't really need to build a library at all. You can just place the source code for QpuListView in the same project as your application.

TheKedge
17th August 2006, 12:49
How about just sub-classing QDockWidget and putting a QGroupBox into it. Stick all your buttons and widgets into the group box.
you get something like the attachement. And it's dockable.

gsQT4
17th August 2006, 15:52
:) Thanks again Chicken Blood Machine. Including the Widgets sources in the project worked perfectly. Now I'll attempt to port it to QT4. It ports OK, except for a function that uses QObjectListIterator. I'll have to research what QT4 is using for a QObjectListIterator and how it works.

Kedge, thanks for the suggestion. I'll look at that to.

DoNaLd
11th December 2006, 23:35
Hi gsQT4,

plz. have you already this QpuListView ported to Qt4 ?

gsQT4
9th March 2007, 21:00
DoNaLd,

I did port it for QT4. It still requires qt3support, but does appear to work. I'm a novice developer, so I cannot say the way I implemented to port is correct.

Glenn


/************************************************** *****
**
** Definition of QpuListView
**
** Copyright (C) 2004 Prashanth N Udupa
**
** QpuListView is an enhanced list view for providing
** XP look and feel left pane widget
** you and distribute and modify is under terms of GNU
** Library General Public License as published by the
** Free Software Foundation; either version 2, or (at
** your option) any later version.
**
************************************************** ******/

/************************************************** *************************
QpuListView.h
-------------------
begin : Thu 03 June 2004
copyright : (C) 2004 by Prashanth Udupa
email : udupaprashanth@yahoo.com
************************************************** *************************/

/************************************************** *************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
************************************************** *************************/

/**
With contributions from Volker Götz
*/

#ifndef Qpu_LIST_VIEW_H
#define Qpu_LIST_VIEW_H

#include <q3listview.h>
//Added by qt3to4:
#include <QPixmap>
#include <QResizeEvent>

/**
Some notes

1. This list view should only be used for tree
structured single column data.
2. By default the first column is created.
3. Header is stretchable and is hidden
*/

class QpuListView;
class QpuListViewItem;

class QpuListViewItem : public Q3ListViewItem
{
public:
QpuListViewItem(QpuListView* parent, const QString &text1);
QpuListViewItem(QpuListViewItem* parent, const QString &text2);
~QpuListViewItem();

void setMinimumHeight(int height) { _MinHeight = height; }
int minimumHeight() const { return _MinHeight; }

int height() const;
void setup();

void paintCell(QPainter* p, const QColorGroup &cg, int column, int width, int align);
void paintBranches(QPainter* p, const QColorGroup &cg, int w, int y, int h);
void paintFocus(QPainter *p, const QColorGroup &cg, const QRect &r);

virtual bool isWidgetItem() const { return false; }

QpuListViewItem* findItem(const QString &text);

void setOpen(bool o);

friend class QpuListView;
friend class QpuPainter;

protected:
void invalidateChildrenHeight();
void setHeight(int height); // reimplemented from QListView
QRect itemRect() const;
QpuListView* qpuListView() const {
return (QpuListView*)(listView());
}

protected:
enum ItemType {
TopLevelItem = 0,
ChildItem,
LastTopLevelItem
} _ItemType;
void setItemType(QpuListViewItem::ItemType type);
const QpuListViewItem* getItemBelow() const;
int belowDepthDiff();
int belowDepthDiff() const;

public:
static QPixmap* DownArrow;
static QPixmap* UpArrow;
QpuListViewItem* _ItemBelow;

private:
int _MinHeight;
};


class QpuWidgetItem : public QpuListViewItem
{
public:
// It would not look good if the top level list view item
// was a widget.
// QpuWidgetItem(QpuListView* parent, const QString &text1);
QpuWidgetItem(QpuListViewItem* parent, QWidget* widget=0);
~QpuWidgetItem();

void setWidget(QWidget *widget);
QWidget* widget() const;

void setAutoDelete(bool del);
bool autoDelete() const;

bool isWidgetItem() const { return true; }

void paintCell(QPainter* p, const QColorGroup &cg, int column, int width, int align);

friend class QpuListView;
friend class QpuPainter;

protected:
virtual QWidget *createWidget() { return 0; }

public:
QWidget* _Widget;
bool _AutoDelete;
};


class QpuListView : public Q3ListView
{
Q_OBJECT
public:
QpuListView(QWidget* parent=0, const char *name=0);
~QpuListView();

QpuListViewItem* findItem(const QString &text) const;

void setLastItem(QpuListViewItem* item) { _LastItem = item; }
QpuListViewItem* lastItem() const { return _LastItem; }

void setXpLook(bool val);
bool getXpLook() const;

void clear();

protected slots:
void mouseOverItem(Q3ListViewItem* item);
void itemClicked(Q3ListViewItem *item);
void itemExpanded(Q3ListViewItem*);

protected:
void viewportResizeEvent ( QResizeEvent *e );

protected:
bool _XpLook;
QpuListViewItem* _LastItem;
};

#endif

gsQT4
9th March 2007, 21:21
Here are the files.

gsQT4
18th March 2007, 18:12
It looks like the port is not working properly. If you look at the attached pictures, you will see the difference. The main issue is the background color. Notice that the QT3 version paints the entire ListView object purple. The QT4 version does not paint the entire background. I've tried many things, and it looks like it is painted when a QPuListViewItem or QpuWidgetItem is added to the QPUListView object. The QT3 version will paint the Listview objects when there are no items.

Does anyone have a suggestion on how to fix this?

Thanks,
Glenn

wysota
18th March 2007, 18:55
Did you try setting the QPalette::Base brush?

gsQT4
18th March 2007, 20:30
I added this line to the function that creates the QPUListView object.

taskView -> Q3ListView::setBackgroundRole(QPalette::Base) ;

This will make the background white. If I set it to Dark or Window, it is still white when there are no QPUListViewItem or QPUListViewWidgets inserted into the QPUListView object. If I insert a QPUListViewItem it will make the background under the QPUListViewItem object dark or light grey. The rest of it is still white. I'm trying to make the entire back ground the color of the Window.

wysota
18th March 2007, 20:56
I don't know if I understand the problem, but the solution I mentioned seems to work fine for me...

QPalette::Base of the list view is set to light yellow and QPalette::Window of the parent widget is set to light green (just to distinguish the background).

gsQT4
19th March 2007, 02:35
What did you compile this on? I'm using Linux and GCC. Could you the code of you example? Thanks.

wysota
19th March 2007, 10:41
Linux + GCC :) There is no code, I mocked it in Designer. This is a QListView (or QListWidget, I don't remember) that has QPalette::Base colour component changed to light yellow inside a QWidget that has its QPalette::Window colour component changed to light green.

An equivalent code is more/less:

QWidget *wgt = new QWidget(...);
QHBoxLayout *l = new QHBoxLayout(wgt);
QListView *lv = new QListView;
l->addWidget(lv);
QPalette p = lv->palette();
p.setColor(QPalette::Base, QColor(255,255,100));
lv->setPalette(p);
p = wgt->palette();
p.setColor(QPalette::Window, QColor(100,255,100));
wgt->setPalette(p);

wysota
19th March 2007, 16:32
Just a quick screenshot of what I implemented today :)

gsQT4
20th March 2007, 01:48
Wysota,

That works great. I added it to the QPUListView constructor. Thanks.

The example you show in the last post, was the made with QT 4's QListView?

Glenn

wysota
20th March 2007, 10:39
The example you show in the last post, was the made with QT 4's QListView?

No, this is a completely custom widget derived from QScrollArea. You can add separate "tasks" to it and assign any widget you want as the "body" of the task. You can even fill the widget with tasks in Designer. Of course the whole thing is stylable, so you can make it look just like the WinXP original.

DoNaLd
16th November 2007, 10:44
gsQT4,

do you have some working version of QpuListView in only Qt4 ?
Or if you have with this some issues, maybe i can help you.

santhoshv84
14th May 2008, 11:39
Hai,
I tried out the Pulistview. I created an application with one Listview. I implemented this QPUListView class in the project. But i got lot of errors.
I added QT3 Support Library in the Project. I am using QT 4.3.4. So i am not able to modify this class as i am new to QT.

Could you please help to solve this problem.

Thanks and regards.
V. Santhosh