[SOLVED] How to add Word-Wrapping to a QPushButton

I'm working on a Qt project and I have a QPushButton on which I'd like to allow word wrapping:
I know I can change it to a QLabel, but due to the specific purpose of the application, it needs to be clickable (so I think that means it must be a QPushButton). I've searched around online a bit and the only solution I've been able to find is "inheriting." However, I can't seem to figure out how to do it. Can anyone help? Thanks!
Last edited by tony5429 (2009-08-22 19:20:38)

I don't think that is possible, as it is against QPushButton's intended design.
However, you could easily derive a class from QLabel and overload the
virtual void QWidget::keyPressEvent ( QKeyEvent * event )
function or install an event filer (http://doc.trolltech.com/4.5/eventsandfilters.html)
on a "plain" QLabel to do the exactly same.

Similar Messages

  • How Can I Word-wrap a Value?

    How can I force a selection in a drop-down menu to word-wrap in the value portion of an object?  I can achieve my desired result in the caption portion by increasing the height of the object.  However, when I increase the size of the object, the value portion does not wrap.

    Are you sure that a drop down menu is the best option for what you're doing? Maybe another Object type would suit your purposes better--like radio buttons.
    Anyway, You can edit the XML source and add a CDATA tag around the items in your list. So, if you have a drop down list with {Something really long goes here, Something else really long here, And another really long thing} as your options, click on the XML Source tab.
    Add
    <![CDATA[Something really long
    goes here]]>
    Now, this will break the line as you're wanting to do, but it's going to cause a different problem--The list of items was originally selected by the first, second, and third lines in the dropdown list. They still are. So, you have 6 different lines, and only the first three can select something. If you're just wanting to have a dropdown that the user selects to read a list and not to select something, then this is probably ok. If you want the user to select an item, then this is a terrible idea.
    If your lines are just a little bit too long to fit, you can set the value's font to "0" Then it will shrink and expand the font size to fit the largest selection. Two notes, the dropdown arrow will cover the last bit of the line, and there is a limit to how small it can get.

  • How to add words from a JTextField to a JList

    Im working on my final project for Java programming class using JApplet.
    Im trying to create a spelling test/wordfind
    I want to be able to have the user type a word in the JtextField press the "Add" button (Jbutton) and have the word be added to the JList.
    then click the "Start" Button and have the all the words from the JList be put in random stops in a panel and fill around all the words with random letters.
    then when the user clicks on the letter of the words they are finding it will change colors if they click on it again it will change back to its original color.
    So far I have my layout set up its adding the proper Listeners and events to achieve the desired results.
    I know this is way more advanced than what My Instructor is even teacher but I am very interested in Java and want to learn a lot more about it.
    If anyone has suggestions or know where i can find the information Im looking for please let me know.
    Thanks
    Code I have so Far:
    * @(#)SpellingTest.java
    * SpellingTest Applet application
    * @author
    * @version 1.00 2010/11/10
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SpellingTest extends JApplet implements ActionListener {
         Image img;
         ImageIcon icon;
         private Image title;
         JTextField word;
         JButton addWord;
         JLabel label;
         JList wordList;
         public void init() {//opening init
                   getContentPane().setLayout(null);
                   getContentPane().setBackground(Color.WHITE);
                   title = getImage(getDocumentBase(), "title.jpg");
                   //The text field
                   word = new JTextField();
                   word.setLocation(190,100);
                   word.setSize(85,30);
                   getContentPane().add(word);
                   word.addActionListener(this);
                   //The addWord button
                   addWord = new JButton("ADD");
                   addWord.setLocation(295, 100);
                   addWord.setSize(90,30);
                   getContentPane().add(addWord);
                   addWord.setBackground(new Color(146, 205, 220));
                   addWord.addActionListener(this);
                   //The label
                   label = new JLabel("Type your spelling words:");
                   label.setLocation(25, 65);
                   label.setSize(250,100);
                   getContentPane().add(label);
                   label.setForeground(new Color(146, 205, 220));
                   //The List
                   wordList = new JList();
                   JScrollPane scrollPane = new JScrollPane(wordList,
                   ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                   ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                   scrollPane.setLocation(25,150);
                   scrollPane.setSize(150,300);
                   getContentPane().add(scrollPane);
         }//closing init
         public void actionPerformed (ActionEvent ae){
              Object obj = ae.getSource();
              String text = word.getText();
              if (obj == addWord){
                   if (text.length()>0);
                   wordList.addString("");
         public void paint(Graphics g) {
              super.paint(g);
    }

    Read the first posting titled "Welcome to the new home" to learn how to use code tags. Then you can edit your posting so the code is formatted and readable.
    I want to be able to have the user type a word in the JtextField press the "Add" button (Jbutton) and have the word be added to the JList.Read the JList API and follow the link to the Swing tutoral on "How to Use Lists" where you will find a working example.
    So far I have my layout Actually you haven't. You should learn how to use layout managers. Again the Swing tutorial explains what layout managers are and provides working example of using them.
    I am very interested in Java and want to learn a lot more about it.A great place to start is by read tutorials because they always contain working example. Here are some [url http://download.oracle.com/javase/tutorial/]Java tutorrial.

  • [SOLVED] How to add modules to build with the kernel?

    Hello i´m trying to learn how to build my own custom kernel and doing it the arch way https://wiki.archlinux.org/index.php/Ke … raditional. But unfortunately dm-crypt was not included in the kernel so it all failed.
    svart_alg% sudo mkinitcpio -k 3.15.6 -c /etc/mkinitcpio.conf -g /boot/initramfs-test.img
    ==> Starting build: 3.15.6
    -> Running build hook: [base]
    -> Running build hook: [udev]
    -> Running build hook: [autodetect]
    -> Running build hook: [modconf]
    -> Running build hook: [lvm2]
    ==> ERROR: module not found: ‘dm-snapshot’
    -> Running build hook: [encrypt]
    ==> ERROR: module not found: ‘dm-crypt’
    -> Running build hook: [block]
    -> Running build hook: [filesystems]
    -> Running build hook: [keyboard]
    -> Running build hook: [fsck]
    ==> WARNING: No modules were added to the image. This is probably not what you want.
    ==> Creating gzip initcpio image: /boot/initramfs-test.img
    ==> WARNING: errors were encountered during the build. The image may not be complete.
    I have never don any of this before and have no idea of how to add a missing module to the kernel i´m building. So i search on internet and had a very hard time finding a good guide for this but i fond one possible solution. https://www.kernel.org/doc/Documentatio … odules.txt
    svart_alg% make -C /home/nigro_alko/Kernel/linux-3.15.6 M=/home/nigro_alko/Kernel/cryptsetup-1.6.5/Makefile.in
    make: Entering directory ‘/home/nigro_alko/Kernel/linux-3.15.6‘
    mkdir: cannot create directory ‘/home/nigro_alko/Kernel/cryptsetup-1.6.5/Makefile.in’: Not a directory
    scripts/Makefile.build:44: /home/nigro_alko/Kernel/cryptsetup-1.6.5/Makefile.in/Makefile: Not a directory
    make[1]: *** No rule to make target ‘/home/nigro_alko/Kernel/cryptsetup-1.6.5/Makefile.in/Makefile’. Stop.
    Makefile:1310: recipe for target ‘_module_/home/nigro_alko/Kernel/cryptsetup-1.6.5/Makefile.in’ failed
    make: *** [_module_/home/nigro_alko/Kernel/cryptsetup-1.6.5/Makefile.in] Error 2
    make: Leaving directory ‘/home/nigro_alko/Kernel/linux-3.15.6‘
    So is there any one that have time to help a lost little newbie i would bee very happy  :-)
    Last edited by Moosey_Linux (2014-07-29 15:00:40)

    karol wrote:Why do you want a custom kernel in the first place?
    Moosey_Linux wrote:i´m trying to learn how to build my own custom kernel
    Reason enough IMO. But anyway... you refer to the Traditional build method in the wiki, but is it possible you didn't really read it? Or maybe you only skimmed it? Did you run make menuconfig? Did you try to build everything in instead of using modules? That mkinitcpio output suggests that you did.
    As suggested there for first-timers, it's a good idea to start with a kernel configuration that is known to work - the Arch config is the obvious choice, but there are other sources e.g. http://kernel-seeds.org/ .

  • [SOLVED]How to add multiple gateways in Arch

    Hi, can someone please advise how to add multiple gateway address for multiple interfaces.
    In my case I have two wired LAN cards. I use Arch network daemon to manage my NIC's.
    I know in Gentoo it could be done through : 'gateway_ethX=( "default gw xx.xx.xx.xx dev ethX" )'
    but doing so in arch wont connect to router/gateway.
    Also in rc.conf it says :
    # Routes to start at boot-up (in this order)
    # Declare each route then list in ROUTES
    #   - prefix an entry in ROUTES with a ! to disable it
    How to declare each route, and then how to list it in ROUTES?
    I read the following thread:
    http://bbs.archlinux.org/viewtopic.php?id=52992, but after adding the suggested lines in rc.conf and restarting the network it fails and says hostname not found.
    Thanks.
    Last edited by kapz (2009-10-08 18:53:39)

    In that case, your routing table should look something like this:
    Kernel IP routing table
    Destination Gateway Genmask Flags Metric Ref Use Iface
    192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
    192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
    0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth1
    rc.conf:
    eth0="eth0 192.168.1.14 netmask 255.255.255.0 broadcast 192.168.1.255"
    eth1="eth1 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255"
    INTERFACES=(eth0 eth1)
    # You may need to add 'dev eth1' to the end of this after '.1.1'
    gateway="default gw 192.168.1.1"
    ROUTES=(gateway)
    Last edited by fukawi2 (2009-10-06 21:55:49)

  • How to add  word document

    Hi ..
    Our aim is to see word document after clicking  context menu(rigt click of mouse) at ANALYZER..
    To see this document,what procedur we have to follow? HOw can we add this word document..?

    Hi,
    As of 7.0 we can upload or main tain documents in deocument are but from 7.3 we can create and maintain in Bex QD it self
    check the below link...
    http://help.sap.com/saphelp_nw73/helpdata/en/43/4e3a1c430e324ee10000000a422035/content.htm
    Regards,
    Satya

  • [SOLVED]How to add OAL driver level functionality in the AM335x BSP source code???

    Dear developers,
    Greetings!!!
    As, my platform is WinCE 7 with AM335x BSP and I would like to copy one driver and update the driver as per my requirements. The location from where I have taken the existing driver is - 
    BSP\SRC\CSP\COMMON_TI_AMXX\OAL --
    Existing diver is OALRTC and new driver is abc_I2C under the same location and I have tailored the driver according to my requirements.
    One funciton is OALIoCtlHalInitRTC and the call is made from BSP\SRC\OAL\oallib\ioctl.c and the calling funciton is BSPIoCtlHalInitRegistry
    In my case, I am calling my OAL API as OALIoCtlHalInitPHY..
    But the thing is that I am getting linking error during the time of compiling and is shown below -
    Error 6 Error(s) in directory "C:\WINCE700\platform\AM335x\SRC\OAL\OALEXE\". C:\WINCE700\build.log 2800
    Error 7 oal.lib(ioctl.obj) : error LNK2019: unresolved external symbol OALIoCtlHalInitPHY referenced in function BSPIoCtlHalInitRegistry C:\WINCE700\build.log 2801
    Error 8 fatal error LNK1120: 1 unresolved externals {log="C:\WINCE700\build.log(2802)"} C:\WINCE700\OSDesigns\Enventure\Enventure\Wince700\AM335x_ARMV7_Retail\cesysgen\platform\AM335x\target\ARMV7\retail\oal.exe
    Error 9 NMAKE : fatal error U1077: 'C:\WINCE700\sdk\bin\i386\ARM\link.EXE' : return code '0x460' C:\WINCE700\build.log 2803
    Error 10 TargetExeFiles -nologo BUILDMSG=Stop. BUILDROOT=C:\WINCE700\platform\AM335x LINKONLY=1 NOPASS0=1 failed - rc = 2. C:\WINCE700\build.log 2805
    Error 11 BLDDEMO: ERROR: There were errors building CEBASE. C:\WINCE700\build.log 2837
    As I searched but I am unable to solve the issue. 
    Any one suggest that how to solve the issue???

    Hello Friends,
    The above problem is self solved..

  • [Solved] How To Add Blank Space In Prompt With zsh

    How can I get zsh to show the full directory path I'm in, instead of just my hostname?
    Last edited by shoober420 (2014-07-31 16:53:51)

    You should be able to just add a space in your prompt. Can you post the prompt you have now?
    Have a look at https://wiki.archlinux.org/index.php/Color_Bash_Prompt
    PS1='[\u@\h \W]\$ '
    The prompt goes between the ' ' - the last two characters are $ and a space. Try doing something similar.

  • How to make word wrapping off in JTextPane...

    Hi,
    I m creating n RTF TextEditor using JTextPane....
    How can i make the wordwrapping off in JTextPane.
    It doesnt hav the property like
    setLineWrap(true);
    setWrapStyleWord(false); like Textarea...
    So how can i do that?
    Its Urgent..
    Regards,
    Danish

    Its Urgent..I searched the forum using "jtextpane wrapping" to find other postings on this topic. I find some suggestions from the first page of hits. So you could have found an answer 5 hours ago. I guess it isn't that urgent after all.

  • [SOLVED] How to add files to iso file for Live USB ?

    I created a Live USB by dd command of the dual iso. Now I want to write a shell script to collect commands I need during installation process. Since dd command writes from sector to sector on the USB drive, it is not editable. How can I add my shell script to be available when booting by the arch Live USB ?
    Last edited by etrader (2013-03-10 05:24:17)

    jasonwryan wrote:Not an installation issue, moving to Newbie Corner...
    Sorry for inappropriate posting. This is an advanced customization, but I need a simple manual approach to add my shell script to the iso archive. Moreover, using archiso needs an arch host, but I hoped to be able to create the Live USB from within other linux distributions, as I do with dd command.

  • [SOLVED] How to add cd drive to wine? (mounted at cdda://sr0)

    Trying to allow wine access to my cd drive and having difficulties.
    My drive automounts at cdda://sr0 and can't figure out a way to get wine to access it. 
    How are you guys managing it?
    Last edited by ctarwater (2011-10-17 01:56:05)

    karol wrote:Run winecfg and go to the 'Drives' tab.
    cdda usually means an AudioCD, never tried that.
    It is an audio cd, I'm playing around with EAC (I know, I know, there are good native replacements).
    If I open the 'drives' tab in winecfg and try 'autodetect' it doesn't list my drive.  If I try to add it manually I have to navigate to it but cdda doesn't exist anywhere for me to navigate to.

  • [SOLVED] How to add data toOutputStream ?

    <p>
    I have following code in managed bean:
    </p>
    <p>
    <font face="courier new,courier" size="2" color="#0000ff">OutputStream out = response.getOutputStream();
    response.setHeader("Content-Disposition", "attachment;filename=\"test.xml\"");
    response.setContentType("application/xml");</font>
    </p>
    <p>
    <font face="courier new,courier" size="2" color="#0000ff">........</font>
    </p>
    <p>
    <font face="courier new,courier" size="2" color="#0000ff">out.flush();
    out.close();
    ctx.responseComplete();</font>
    </p>
    <p>
    How can I add data (i get it from iterator) to OutputStream to send user xml file. ?
    </p>
    <p>
    Kuba
    </p>

    <p>
    Hi Steve,
    </p>
    <p>
    I found solution, I mean this:
    </p>
    <p>
    <font face="courier new,courier" size="2" color="#0000ff">ExternalContext ectx = ctx.getExternalContext();
    HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
    OutputStream out = response.getOutputStream();
    response.setHeader(&quot;Content-Disposition&quot;, &quot;attachment;filename=\&quot;test.xfdf\&quot;&quot;);
    response.setContentType(&quot;vnd.adobe.xfdf&quot;);
        PrintWriter pw = new PrintWriter(out);
        pw.println(&quot;<font color="#ff0000"><em>ANY DATA HERE</em></font>&quot;);
        pw.close();
    out.flush();
    out.close();
    ctx.responseComplete();</font>
    </p>
    <p>
    Kuba
    </p>

  • [SOLVED] How to add dictionary in Claws-mail

    How do I add Norwegian to the Claws-mail spellchecking? Btw, English works fine.
    Last edited by alphahsk (2008-02-04 21:49:50)

    if you use aspell then add proper aspell-no (?) and it should appear in Preferences-Compose-Spell checking
    I found aspell-nb in AUR. Cheers

  • [Solved] How to add launchers to Desktop of gnome 3 ?

    Hi,
    I have gnome 3 installed. I have enabled adding files in desktop. Now my desktop shows home icon and trash. Now i want to add some existing application launcher to desktop. For example i have chromium browser installed and i have added it to favorites. I want to add launcher to desktop as a icon, so that i can click on chrome icon in desktop and use chromium browser. I searched on the google a lot but no luck
    Last edited by ashwin_cse (2013-07-15 14:55:51)

    It is now solved. I installed extensions from here . These extensions make available gnome 2 features in gnome 3 by using native gnome 3 code and not by making to fall back to gnome 2. But these extensions doesn't have one feature i am looking for , which is launchers. For that only i found was to install gnome-panel. Which is a gnome2 thing. Unfortunately i couldn't find any gnome 3 things that would do this. So i installed gnome-panel which contains gnome-desktop-item-edit file. Then i ran the following to create a launcher :
    gnome-desktop-item-edit --create-new ~/Desktop
    But the problem is that the site says it might break with gnome 3 updates.

  • [SOLVED] How to add keyboard shortcuts in XFCE?

    I'm giving XFCE a try lately after all of the changes I'm seeing, I'm trying to add a new shortcut to ease some tasks but I don't have a clue on how to do it.
    I go to Settings -> Keyboard and there to "Application shortcuts". Then I  select to add a new one and point to the script I want to run, but I don't have a clue on how to select the shortcut. I've tried pressing the keys I want to bind, but no way.
    This is what I'm seeing:
    How to choose the actual shortcut?
    Last edited by KaoDome (2012-05-11 13:16:03)

    It is the next screen   Pick the command, click OK.  It then throws up a box telling you to press the key combination.  It will show as you push meta, shift and control modifiers.  When you hit a character that generates a keystroke, it saves it, along with the modifiers.

Maybe you are looking for

  • Captivate 7 does not run the exe on windows xp

    We are using adobe captivate 7 installed (trail version ) in a windows 7 with SP1 computer . when we publish it and run exe in the windows XP (home ) under administrator we get  following error even if the flash player is updated. "" The installed ve

  • Guid Partition or Apple Partition?

    Hey there, my goal is to set up several Hard Drives to be daisy chained for using them to organize Pictures using Lightroom and backing it up. Just one HD I want to be connected via FireWire 800 to the iMac. Before I start adding the Files to the new

  • I can't sign in b/c "your acct is inactive" and I can't register a new acct w/ the same email I used for the original registration. FF7.0.1

    When I try to sign in I get "your acct is inactive" message and no info on how to activate it. When I try to register a new acct, I can't use my email address b/c its associated w/ my "inactive" acct. So I opened a new email acct in order to register

  • HT4623 After upgrading to 6.1 the bluetooth will not pair.

    I reset the iphone 5 because the weather was not updating. It erased the previous bluetooth pairings and now it gives an pairing unsuccesful on the Jabra and the Bose headset. When I tried to back up the iphone to the MacBook, it also gave me an erro

  • Rate Schedule for Items

    Hi All, We are doing our budgeting in Project Management. We are using centrally controlled planning resource list where we have selected all the items needed for budgeting.But the problem is the rate can be given by user in the project level which m