| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 2 | |
Hi Everyone,
Using Qt 4.3.1.
I am trying to reproduce the (Delphi) toolbar shown in ToolbarOrig. I have added two labels to the toolbar. When I change the text of one label, the toolbar doesn't resize.
How can I force the toolbar to recalc the positions of the actions/widgets?
Updating the text using action->setText didn't work at all. Updating the text using label->setText shows the start of the text. toolbar->updateGeometry isn't doing anything. label->adjustSize shows all of the text, on top of the next/prev buttons.
The doco for QAction add/insertWidget isn't very clear. Eg, it doesn't say who the owner of the widget should be.
Many tahnks in advance.
Tony.
Here is the code so far:
class TRisingMain : public QMainWindow
{
Q_OBJECT
public:
TRisingMain(TRisingApp *app_);
private slots:
void updateDrillToolbar();
private:
Ui::RisingMain ui;
QAction *actionSyllabus;
QLabel *labelSyllabus;
}
TRisingMain::TRisingMain(TRisingApp *app_)
: QMainWindow()
{
QLabel *label = NULL;
ui.setupUi(this);
label = new QLabel( tr("Syllabus:"), ui.toolBarTopics );
ui.toolBarTopics->insertWidget( ui.actionPreviousLevel, label );
labelSyllabus = new QLabel( ui.toolBarTopics );
actionSyllabus = ui.toolBarTopics->insertWidget( ui.actionPreviousLevel, labelSyllabus );
}
void TRisingMain::updateDrillToolbar()
{
labelSyllabus->setText( drill->syllabus->syllabus_name );
ui.toolBarTopics->updateGeometry();
}
// End of code
Attachment:
Attachment:
ToolbarOrig.png Attachment:
ToolbarQt.png
Description: PNG image
Description: PNG image
Message 2 in thread
On onsdag den 12. Marts 2008, Tony Rietwyk wrote:
> Hi Everyone,
>
Try geometryChanged() and updateGeometry() on the label.
Bo.
> Using Qt 4.3.1.
>
> I am trying to reproduce the (Delphi) toolbar shown in ToolbarOrig. I have
> added two labels to the toolbar. When I change the text of one label, the
> toolbar doesn't resize. How can I force the toolbar to recalc the positions
> of the actions/widgets?
>
> Updating the text using action->setText didn't work at all. Updating the
> text using label->setText shows the start of the text.
> toolbar->updateGeometry isn't doing anything. label->adjustSize shows all
> of the text, on top of the next/prev buttons.
>
> The doco for QAction add/insertWidget isn't very clear. Eg, it doesn't say
> who the owner of the widget should be.
>
> Many tahnks in advance.
>
> Tony.
>
>
> Here is the code so far:
>
>
> class TRisingMain : public QMainWindow
> {
> Q_OBJECT
>
> public:
> TRisingMain(TRisingApp *app_);
>
> private slots:
> void updateDrillToolbar();
>
> private:
> Ui::RisingMain ui;
>
> QAction *actionSyllabus;
> QLabel *labelSyllabus;
> }
>
>
> TRisingMain::TRisingMain(TRisingApp *app_)
>
> : QMainWindow()
>
> {
> QLabel *label = NULL;
>
> ui.setupUi(this);
>
> label = new QLabel( tr("Syllabus:"), ui.toolBarTopics );
> ui.toolBarTopics->insertWidget( ui.actionPreviousLevel, label );
>
> labelSyllabus = new QLabel( ui.toolBarTopics );
> actionSyllabus = ui.toolBarTopics->insertWidget( ui.actionPreviousLevel,
> labelSyllabus ); }
>
>
> void TRisingMain::updateDrillToolbar()
> {
> labelSyllabus->setText( drill->syllabus->syllabus_name );
> ui.toolBarTopics->updateGeometry();
> }
>
> // End of code
--
[ signature omitted ]
Message 3 in thread
> From: Bo Thorsen [mailto:bo@xxxxxxxxxxxxxxxxxxxxx]
> Sent: Wednesday, 12 March 2008 18:13
> On onsdag den 12. Marts 2008, Tony Rietwyk wrote:
> > Hi Everyone,
> >
> Try geometryChanged() and updateGeometry() on the label.
>
> Bo.
>
Thanks for that - updateGeometry did the trick. I am suprised that
adjustSize didn't do that itself!
geometryChanged doesn't compile for a QLabel. Would that be used in designer
plug-ins?
Regards,
Tony
> > Using Qt 4.3.1.
> >
> > I am trying to reproduce the (Delphi) toolbar shown in
> ToolbarOrig. I have
> > added two labels to the toolbar. When I change the text of
> one label, the
> > toolbar doesn't resize. How can I force the toolbar to
> recalc the positions
> > of the actions/widgets?
> >
> > Updating the text using action->setText didn't work at all.
> Updating the
> > text using label->setText shows the start of the text.
> > toolbar->updateGeometry isn't doing anything.
> label->adjustSize shows all
> > of the text, on top of the next/prev buttons.
> >
> > The doco for QAction add/insertWidget isn't very clear. Eg,
> it doesn't say
> > who the owner of the widget should be.
> >
> > Many tahnks in advance.
> >
> > Tony.
> >
> >
> > Here is the code so far:
> >
> >
> > class TRisingMain : public QMainWindow
> > {
> > Q_OBJECT
> >
> > public:
> > TRisingMain(TRisingApp *app_);
> >
> > private slots:
> > void updateDrillToolbar();
> >
> > private:
> > Ui::RisingMain ui;
> >
> > QAction *actionSyllabus;
> > QLabel *labelSyllabus;
> > }
> >
> >
> > TRisingMain::TRisingMain(TRisingApp *app_)
> >
> > : QMainWindow()
> >
> > {
> > QLabel *label = NULL;
> >
> > ui.setupUi(this);
> >
> > label = new QLabel( tr("Syllabus:"), ui.toolBarTopics );
> > ui.toolBarTopics->insertWidget( ui.actionPreviousLevel, label );
> >
> > labelSyllabus = new QLabel( ui.toolBarTopics );
> > actionSyllabus = ui.toolBarTopics->insertWidget(
> ui.actionPreviousLevel,
> > labelSyllabus ); }
> >
> >
> > void TRisingMain::updateDrillToolbar()
> > {
> > labelSyllabus->setText( drill->syllabus->syllabus_name );
> > ui.toolBarTopics->updateGeometry();
> > }
> >
> > // End of code
>
>
>
> --
>
> Thorsen Consulting ApS - Qt consulting services
> http://www.thorsen-consulting.dk
>
> --
> To unsubscribe - send a mail to
> qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the
> subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]