Results 1 to 20 of 20

Thread: custom slots / generated ui

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 1 Time in 1 Post

    Default Re: custom slots / generated ui

    Try the signal "triggered()" of your actions instead of "activated()":

    #
    QObject::connect(actionExit, SIGNAL(triggered()), this, SLOT(exit_slot()));
    #
    QObject::connect(actionNew_2D_Scene, SIGNAL(triggered()), this, SLOT(addScene2D_slot()));

  2. #2
    Join Date
    Sep 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    MacOS X Windows
    Thanks
    2

    Default Re: custom slots / generated ui

    Hi all

    First of all, thanks for the input! Alas, none of it worked.

    I tried something very simple and get exceptions too. So I assume the problem is rooted deeper. I have added a simple widget manipulation to generat0rx.cpp:
    Qt Code:
    1. #include "generat0rx.h"
    2. #include "qmessagebox.h"
    3. #include <QxtLogger>
    4. #include <QxtBasicFileLoggerEngine>
    5.  
    6. generat0rX::generat0rX(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags)
    7. {
    8. ui.setupUi(this);
    9. //QObject::connect(actionExit, SIGNAL(activated()), this, SLOT(exit_slot()));
    10. //QObject::connect(actionNew_2D_Scene, SIGNAL(activated()), this, SLOT(addScene2D_slot()));
    11.  
    12. //Start logging
    13. qxtLog->addLoggerEngine("FileLogger", new QxtBasicFileLoggerEngine("log/g0x.log"));
    14. qxtLog->info("Huhu INFO log entry!");
    15.  
    16.  
    17. outputTabTextEdit->append("TEST");
    18. }
    19.  
    20. generat0rX::~generat0rX()
    21. {
    22.  
    23. }
    24.  
    25. void generat0rX::exit_slot()
    26. {
    27. QMessageBox msgBox;
    28. msgBox.setText("SLOT: exit_slot triggered");
    29. msgBox.exec();
    30.  
    31. //qApp->quit();
    32. //qApp->exit();
    33. }
    34.  
    35. void generat0rX::addScene2D_slot()
    36. {
    37. QMessageBox msgBox;
    38. msgBox.setText("SLOT: addScene2D triggered");
    39. msgBox.exec();
    40. }
    To copy to clipboard, switch view to plain text mode 

    This line was added in the constructor:
    Qt Code:
    1. outputTabTextEdit->append("TEST");
    To copy to clipboard, switch view to plain text mode 

    and even THIS raises an exception. There must be something fundamentally wrong with the way I call ui elements...(I am using multiple inheritance btw). Just to make sure you get the full picture, here is generat0rx.h as well:

    Qt Code:
    1. #ifndef GENERAT0RX_H
    2. #define GENERAT0RX_H
    3.  
    4. #include <QtGui/QMainWindow>
    5. #include "ui_generat0rx.h"
    6.  
    7. class generat0rX : public QMainWindow, private Ui::generat0rXClass
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. generat0rX(QWidget *parent = 0, Qt::WFlags flags = 0);
    13. ~generat0rX();
    14.  
    15. public slots:
    16. void exit_slot(void);
    17. void addScene2D_slot(void);
    18.  
    19. private:
    20. Ui::generat0rXClass ui;
    21. };
    22. #endif // GENERAT0RX_H
    To copy to clipboard, switch view to plain text mode 

    This is getting really frustrating :s

    Here is the call stack:
    Qt Code:
    1. > QtGuid4.dll!QTextEdit::append(const QString & text="TEST") Line 2617 + 0x7 bytes C++
    2. generat0rX.exe!generat0rX::generat0rX(QWidget * parent=0x00000000, QFlags<enum Qt::WindowType> flags={...}) Line 17 + 0x2e bytes C++
    3. generat0rX.exe!main(int argc=1, char * * argv=0x0079fab0) Line 17 + 0x1d bytes C++
    4. generat0rX.exe!WinMain(HINSTANCE__ * instance=0x01040000, HINSTANCE__ * prevInstance=0x00000000, char * __formal=0x000a2b9a, int cmdShow=1) Line 131 + 0x12 bytes C++
    5. generat0rX.exe!__tmainCRTStartup() Line 547 + 0x2c bytes C
    6. generat0rX.exe!WinMainCRTStartup() Line 371 C
    7. kernel32.dll!76e31194()
    8. [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
    9. ntdll.dll!775eb495()
    10. ntdll.dll!775eb468()
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: custom slots / generated ui

    You are mixing the different approaches of using ui files: See "Using a Designer UI File in Your Application" at the docs.
    Use
    Qt Code:
    1. setupUi(this);
    To copy to clipboard, switch view to plain text mode 
    instead of
    Qt Code:
    1. ui.setupUi(this);
    To copy to clipboard, switch view to plain text mode 
    and rerun qmake.

  4. The following user says thank you to Lykurg for this useful post:

    mboeni (18th October 2010)

  5. #4
    Join Date
    Sep 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    MacOS X Windows
    Thanks
    2

    Default Re: custom slots / generated ui

    Hi Lykurg

    I have read the article you mentioned, but missed the part about setupUI. Changing that as you proposed has solved my main issues. Thanks!

    Cheers,
    Michael

  6. #5
    Join Date
    Sep 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    MacOS X Windows
    Thanks
    2

    Default Re: custom slots / generated ui

    For all other newbies out there, I have put together a little tutorial on how to master the first few steps with Qt4 and MS Visual Studio using the Add-In.

    You find the tutorial here: Beginners Tutorial Qt 4.7 with Visual Studio and the Qt Add-In

    Please comment or PM me in the blog if you find any errors.

    All the best,
    Michael

Similar Threads

  1. Accessing generated pixmaps in html / Custom tooltips
    By Pieter from Belgium in forum Qt Programming
    Replies: 9
    Last Post: 1st August 2009, 16:24
  2. Creating custom slots
    By harb37 in forum Qt Programming
    Replies: 2
    Last Post: 23rd June 2008, 19:10
  3. Replies: 12
    Last Post: 23rd June 2008, 09:05
  4. Replies: 2
    Last Post: 12th July 2007, 10:55
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

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
  •  
Qt is a trademark of The Qt Company.